PDF Writer & PDFlib: Remove from tree.

Now supplied via HaikuPorts packages.

I *think* this was the last component in the tree with a
non-OSI license.
This commit is contained in:
Augustin Cavalier
2017-07-01 18:46:58 -04:00
parent 6544bef00a
commit c7258f02db
473 changed files with 0 additions and 234839 deletions
-1
View File
@@ -164,7 +164,6 @@ SYSTEM_ADD_ONS_PRINT += [ FFilterByBuildFeatures
Gutenprint@gutenprint
PCL5\ Compatible
PCL6\ Compatible
PDF\ Writer
PS\ Compatible
Preview
] ;
-15
View File
@@ -300,12 +300,6 @@ for linkTarget in $(SYSTEM_DEMOS) {
# Deskbar menu entries file
AddFilesToPackage data deskbar : <deskbar>menu_entries ;
# PDF Writer enconding files
CopyDirectoryToPackage data
: [ FDirName $(HAIKU_TOP) src add-ons print drivers pdf encoding ]
: "PDF Writer" : -x Jamfile ;
# licenses
CopyDirectoryToPackage data
: [ FDirName $(HAIKU_TOP) data system data licenses ]
@@ -321,15 +315,6 @@ CopyDirectoryToPackage documentation
: [ FDirName $(HAIKU_TOP) docs apps diskusage ]
: diskusage ;
# Copy documentation and sample programs as per PDFlib Lite's license
# requirement.
CopyDirectoryToPackage documentation
: [ FDirName $(HAIKU_TOP) src libs pdflib doc ]
: pdflib ;
CopyDirectoryToPackage develop sample-code
: [ FDirName $(HAIKU_TOP) src libs pdflib bind pdflib ]
: pdflib ;
# empty directory
AddDirectoryToPackage data empty ;
-146
View File
@@ -1,146 +0,0 @@
PDFlib Lite License Agreement
PDFlib GmbH (Licensor), Tal 40, 80331 Munich, Germany
phone +49 · 89 · 29 16 46 87, fax +49 · 89 · 29 16 46 86
[email protected], [email protected], www.pdflib.com
Note: this license is substantially different than the license for other
products of PDFlib GmbH. This license does not cover products other than those
mentioned in section 1.
1 Definitions
This agreement defines the licensing terms for the software product called
PDFlib Lite 5.0.3. This product will be referred to as »the program« in this
agreement. The program is a copyrighted work whose copyright is held by the
licensor.
The program is delivered with a digital manual which describes its programming
features and their usage (»the documentation«). »Programming samples« shall
mean the sample code which demonstrates use of the program, and which is part
of the distribution. »Original distribution» shall mean the set of all files
comprising the source code package for the program as made available by
licensor.
The term »integrated product« shall be used in this agreement to designate any
product that is made up of both the program and software or hardware developed
or marketed by any other individual or organization. Integrated product shall
mean all components which are required to make reasonable use of the aggregate
software, even if such components are not directly attached to the program. For
example, if integrated product is a virtual printer driver integrated product
means the complete operating system; if integrated product is a word processor
integrated product means the full word processor plus auxiliary components; if
integrated product is a Web application integrated product means all components
for retrieving, processing, and presenting data. (This is not an exhaustive
enumeration.)
By using, modifying or distributing the program (or any work based on the
program), you indicate your acceptance of this license to do so, and all its
terms and conditions for using, copying, distributing or modifying the program
or works based on it. Nothing other than this license grants you permission to
use, modify or distribute the program or its derivative works. These actions
are prohibited by law. If you do not accept these terms and conditions, do not
use, modify or distribute the program.
2 Using the Program
Functional use (running) of the program requires a commercial license which is
outside the scope of this agreement. However, exempt users listed below are
granted a world-wide, royalty-free, non-exclusive license to use the program.
2.1 Open Source Developer Exemption
Use of the program as part of an integrated product is exempt from commercial
licensing provided the integrated product is available under a license which
has been approved by the Open Source Initiative OSI (www.opensource.org),
complete source code for the integrated product is available to anyone free of
charge, and the availability of source code is announced on a publicly
accessible Web site. Source code means the preferred machine-readable form in
which a programmer would modify the software.
2.2 Private non-Profit User Exemption
Non-profit uses of the program by a private individual are exempt from
commercial licensing. For-profit use by individuals and non-profit use by
organizations do not fall under this exemption.
2.3 Educational and Research Exemption
Use of the program by educational institutions and individuals for educational
and research purposes is exempt from commercial licensing. Other uses (e.g.,
administrative) by educational institutions do not fall under this exemption.
3 Redistribution
Redistribution in binary or source form by a commercial organization to any
third party are permitted provided that all of the following conditions are
met. Redistributing the program under these conditions does not necessarily
give the recipient the right to use the program; using the program is always
subject to the conditions in section 2.
3.1 Modifications
If you have modified the program, you must include prominent notices in stating
that you have modified the programs files, your name, your e-mail address (if
any) and the date and purpose of any change.
PDF files generated with the program must include the same Producer entry in
the document info field as those generated with the original (unmodified)
program. Changing the Producer entry renders this license invalid.
3.2 Source Code Redistribution
Redistributions of source code must include all files which are part of the
original distribution. Omitting one or more files would result in a
distribution which is not compliant with this license.
3.3 Binary Redistribution
Redistributions in binary (compiled) form must include this license, the
documentation, and programming samples. Not all programming samples must be
included, but only the samples for programming languages which are actually
supported by the binary distribution. As an alternative to including the
documentation in a binary distribution, the documentation may also be made
available separately for free download on the Internet in unmodified form. This
»download« exception does not apply to other files which are part of the
original distribution.
4 Reservation of Rights
No rights are granted to the program except as expressly set forth herein. You
may not use, copy, modify, sublicense, or distribute the program except as
expressly provided under this license. Any attempt otherwise to copy, modify,
sublicense or distribute the program is void, and will automatically terminate
your rights under this license.
5 Warranty
The program is provided to you »as is«, without warranty. There is no warranty
for the program, either expressed or implied, including, but not limited to,
the implied warranties of merchantability and fitness for a particular purpose
and non-infringement of third party rights. The entire risk as to the quality
and performance of the program is with you. Should the program prove defective,
you assume the cost of all necessary servicing, repair or correction.
In no event unless required by applicable law or agreed to in writing will
licensor, or any other party who may modify and/or redistribute the program as
permitted above, be liable to you for damages, including any general, special,
incidental or consequential damages arising out of the use or inability to use
the program (including but not limited to loss of data or data being rendered
inaccurate or losses sustained by you or third parties or a failure of the
program to operate with any other programs), even if such holder or other party
has been advised of the possibility of such damages.
6 General
This license is governed by the laws of Germany, excluding choice of law rules.
If any part of this license is found to be in conflict with the law, that part
shall be interpreted in its broadest meaning consistent with the law, and no
other parts of the license shall be affected.
PDFlib Lite License Agreement (created January 21, 2004)
(Converted from PDF to text via Google Quick View)
-1
View File
@@ -4,6 +4,5 @@ SubInclude HAIKU_TOP src add-ons print drivers canon_lips ;
SubInclude HAIKU_TOP src add-ons print drivers gutenprint ;
SubInclude HAIKU_TOP src add-ons print drivers pcl5 ;
SubInclude HAIKU_TOP src add-ons print drivers pcl6 ;
SubInclude HAIKU_TOP src add-ons print drivers pdf ;
SubInclude HAIKU_TOP src add-ons print drivers postscript ;
SubInclude HAIKU_TOP src add-ons print drivers preview ;
-50
View File
@@ -1,50 +0,0 @@
CHANGES
From version 1.5b2 to 2.0b1 (6/27/2003):
- updated to PDFlib Lite 5.0.0
- static linked to PDFlib
- added basic support for stroke/fill opacity (transparency)
- add image cache
- ui clean up of Advanced Settings
- added expanded/collapsed state to bookmarks
- added link destination
- bug fixes
From version 1.5b1 to 1.5b2 (7/5/2002):
- fixed bug in install script
- better position detection of bookmarks on a page
- updated to PDFlib 4.0.3 (both x86 and PPC!)
From version 1.0b1 to 1.5b1 (5/30/2002):
- Added interactive pdf features (Web links, cross references, bookmarks)
- Added advanced settings for configuration of interactive features
- Added bookmarks definition "Sample" file
- Added xref definition sample files "English" and "Deutsch"
- Added Bookmarks.zip sample document (StyledEdit and gP)
- Added sample document that shows the interactive features of PDF Writer (gP document and generated PDF file)
- Added doc info window for configuration of PDF document information
- Fixed Document information is now UCS2 encoded
- Added font embedding configuration window (Fonts->Embedding)
- Added CJK search order configuration window (Fonts->CJK)
- Added Korean font support
- Added pattern support
- Implemented clipping to "stroked" graphic primitives
- Fixed font color is always high color and not the current pattern
- Fixed ClipChar() creates a rectangle if the glyph can not be retrieved from BFont
- Update to PDFlib 4.0.2 (Intel only)
- Fixed: silently exit from OpenTransport() in Print To File cancelation case
- Report information in status window
- Install script copies bookmark and xref definition files to PDF Writer settings directory
- Install script restarts print_server before termination
- Fixed window title of page setup window
-20
View File
@@ -1,20 +0,0 @@
#!/bin/sh
launchdir=$(dirname "$0")
copyattr -d "$launchdir/PDF Writer" "$HOME/config/add-ons/Print/PDF Writer"
# copyattr -d "$launchdir/libpdf.so" "$HOME/config/lib/libpdf.so"
mkdir /boot/home/config/settings/PDF\ Writer
cd $launchdir
cp encoding/* $HOME/config/settings/PDF\ Writer/
mkdir /boot/home/config/settings/PDF\ Writer/bookmarks
cp bookmarks/* /boot/home/config/settings/PDF\ Writer/bookmarks
mkdir /boot/home/config/settings/PDF\ Writer/xrefs
cp xrefs/* /boot/home/config/settings/PDF\ Writer/xrefs
# restart print_server
/boot/beos/system/servers/print_server
alert --info "PDF Writer driver is installed"
-4
View File
@@ -1,4 +0,0 @@
SubDir HAIKU_TOP src add-ons print drivers pdf ;
SubInclude HAIKU_TOP src add-ons print drivers pdf source ;
-47
View File
@@ -1,47 +0,0 @@
PDF Writer 2.0b1
6/27/2003
is now part of the print_kit of the Haiku project.
http://www.haiku-os.org
Developers
Name Email address Native language
Phillipe Houdoin <[email protected]> French
Michael Pfeiffer <[email protected]> German
Former developer:
Simon Gauvin <[email protected]> French/English
Installation
1. Expand the zip file somewhere
2. Open the newly created folder
3. Run the Install script to install the driver
These steps are needed only if you don't have already set up a PDF Writer spooler:
4. Open the Printers preference panel
5. Click Add button
6. Choose local printer (Network printing is untested, feedback welcome!)
7. Type a name for your new PDF Writer spooler
8. Select PDF Writer as kind
9. Select port to output PDF (Print to file to generate PDF files)
10. Click Add button
11. Click Ok button
12. Enjoy!
Changes
Read the "CHANGES" file for the most recent changes.
Known Bugs/Limitations
- Limited alpha transparency support only (bitmap/pattern only)
- Not all drawing modes supported
- No security settings support.
- Clipping to inverse BPicture not supported
Note
- BePDF until version 0.9.4 does not take the alpha channel of transparent bitmaps or patterns into account;
Acrobat Reader shows them properly!
-14
View File
@@ -1,14 +0,0 @@
TODO
(in abitrary order)
- pdf generation
- alpha channel support
- support for more drawing modes (XOR, AND, OR, alpha, blend)
- text attributes
- check: char spacing
- security settings (printing, copying, changing, ...) -> not with PDFlib :(
- password protection (ditto)
- thumbnails? note recent Acrobat Reader doesn't require them; BePDF does not support them.
- optimize CID tables; the mapping from Unicode to CID is not required, it is sufficient
to know whether a code point is in a certain CID table or not! -> use bitfield instead
@@ -1,13 +0,0 @@
# This is the PDF Writer bookmarks definition file!
# The next line is mandatory.
Bookmarks 2.0
# PDF Writer searches for this file in directory:
# /boot/home/config/settings/PDF Writer/bookmarks
# level "font family" "font style" font size
# level has to be between 1 and 10 (both inclusive)
# font family and style and size of the font, expanded or collapsed
1 "Swis721 BT" "Roman" 27.0 expanded
2 "Swis721 BT" "Roman" 20.0 collapsed
3 "Swis721 BT" "Roman" 18.0 collapsed
@@ -1,43 +0,0 @@
#!/bin/sh
/boot/system/apps/BeMail mailto:[email protected] -subject "pdf_writer v.1.0b1 report" -body "Thanks for taking the time to report how pdf_writer v1.0b1 worked for you!
Please edit the following text to reflect your experience when trying pdf_writer:
1 - How did pdf_writed worked?
It crashed/it produced grabage inside the window/it produced gargage all over the screen/it first worked, but stopped working when I did.../other...
2 - more information:
<put here some additionnal information/comments>
--------------------------------------------------------------------------
Please do not edit the information below, unless you don't want to disclose some information it contains:
-- Version app_server:
`/bin/version /system/servers/app_server`
-- Version print_server:
`/bin/version /system/servers/print_server`
-- Version libbe.so:
`/bin/version /system/lib/libbe.so`
-- System print_server add-ons:
`/bin/ls -lt /boot/beos/system/add-ons/Print/*`
-- Custom print_server add-ons:
`/bin/ls -lt /boot/home/config/add-ons/Print/*`
-- System libraries:
`/bin/ls -lt /boot/beos/system/lib/`
-- Custom libraries:
`/bin/ls -lt /boot/home/config/lib/`
-- PDF Encoding files:
`/bin/ls -lt /boot/home/config/settings/PDF\ Writer/`
-- Latest pdf_writer.log:
`/bin/cat /tmp/pdf_writer.log`
"
Binary file not shown.
@@ -1,33 +0,0 @@
<html>
<head>
<title>User Guide</title>
</head>
<body>
TODO!
<h2>Installation</h2>
<ol>
<li>Open <b>Printers</b> preference panel:<br>
<img src="images/preferences_printers.jpeg">&nbsp;<img src="images/printers.jpeg">
<li>Click <b>Add</b> button to add a new printer spool:<br>
<img src="images/add_printer.jpeg">
<li>Choose <b>Local Printer</b> and click <b>Ok</b> button. The <i>Add Local Printer</i> window show up:<br>
<img src="images/add_local_printer.jpeg">
<li>Click <b>Add</b> button to validate printer spool settings.
The <i>Printer Model</i> Canon Bubble Jet window show up:<br>
<img src="images/printer_model.jpeg">
</ol>
</body>
</html>
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

@@ -1,260 +0,0 @@
% Encoding definition for PDFlib
% t1enc0
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: glyph name index (decimal) % index (hex)
space 0 % 0x00
exclam 1 % 0x01
quotedbl 2 % 0x02
numbersign 3 % 0x03
dollar 4 % 0x04
percent 5 % 0x05
ampersand 6 % 0x06
quotesingle 7 % 0x07
parenleft 8 % 0x08
parenright 9 % 0x09
asterisk 10 % 0x0a
plus 11 % 0x0b
comma 12 % 0x0c
hyphen 13 % 0x0d
period 14 % 0x0e
slash 15 % 0x0f
zero 16 % 0x10
one 17 % 0x11
two 18 % 0x12
three 19 % 0x13
four 20 % 0x14
five 21 % 0x15
six 22 % 0x16
seven 23 % 0x17
eight 24 % 0x18
nine 25 % 0x19
colon 26 % 0x1a
semicolon 27 % 0x1b
less 28 % 0x1c
equal 29 % 0x1d
greater 30 % 0x1e
question 31 % 0x1f
at 32 % 0x20
A 33 % 0x21
B 34 % 0x22
C 35 % 0x23
D 36 % 0x24
E 37 % 0x25
F 38 % 0x26
G 39 % 0x27
H 40 % 0x28
I 41 % 0x29
J 42 % 0x2a
K 43 % 0x2b
L 44 % 0x2c
M 45 % 0x2d
N 46 % 0x2e
O 47 % 0x2f
P 48 % 0x30
Q 49 % 0x31
R 50 % 0x32
S 51 % 0x33
T 52 % 0x34
U 53 % 0x35
V 54 % 0x36
W 55 % 0x37
X 56 % 0x38
Y 57 % 0x39
Z 58 % 0x3a
bracketleft 59 % 0x3b
backslash 60 % 0x3c
bracketright 61 % 0x3d
asciicircum 62 % 0x3e
underscore 63 % 0x3f
grave 64 % 0x40
a 65 % 0x41
b 66 % 0x42
c 67 % 0x43
d 68 % 0x44
e 69 % 0x45
f 70 % 0x46
g 71 % 0x47
h 72 % 0x48
i 73 % 0x49
j 74 % 0x4a
k 75 % 0x4b
l 76 % 0x4c
m 77 % 0x4d
n 78 % 0x4e
o 79 % 0x4f
p 80 % 0x50
q 81 % 0x51
r 82 % 0x52
s 83 % 0x53
t 84 % 0x54
u 85 % 0x55
v 86 % 0x56
w 87 % 0x57
x 88 % 0x58
y 89 % 0x59
z 90 % 0x5a
braceleft 91 % 0x5b
bar 92 % 0x5c
braceright 93 % 0x5d
asciitilde 94 % 0x5e
space 95 % 0x5f
exclamdown 96 % 0x60
cent 97 % 0x61
sterling 98 % 0x62
currency 99 % 0x63
yen 100 % 0x64
brokenbar 101 % 0x65
section 102 % 0x66
dieresis 103 % 0x67
copyright 104 % 0x68
ordfeminine 105 % 0x69
guillemotleft 106 % 0x6a
logicalnot 107 % 0x6b
hyphen 108 % 0x6c
registered 109 % 0x6d
macron 110 % 0x6e
degree 111 % 0x6f
plusminus 112 % 0x70
twosuperior 113 % 0x71
threesuperior 114 % 0x72
acute 115 % 0x73
mu 116 % 0x74
paragraph 117 % 0x75
periodcentered 118 % 0x76
cedilla 119 % 0x77
onesuperior 120 % 0x78
ordmasculine 121 % 0x79
guillemotright 122 % 0x7a
onequarter 123 % 0x7b
onehalf 124 % 0x7c
threequarters 125 % 0x7d
questiondown 126 % 0x7e
Agrave 127 % 0x7f
Aacute 128 % 0x80
Acircumflex 129 % 0x81
Atilde 130 % 0x82
Adieresis 131 % 0x83
Aring 132 % 0x84
AE 133 % 0x85
Ccedilla 134 % 0x86
Egrave 135 % 0x87
Eacute 136 % 0x88
Ecircumflex 137 % 0x89
Edieresis 138 % 0x8a
Igrave 139 % 0x8b
Iacute 140 % 0x8c
Icircumflex 141 % 0x8d
Idieresis 142 % 0x8e
Eth 143 % 0x8f
Ntilde 144 % 0x90
Ograve 145 % 0x91
Oacute 146 % 0x92
Ocircumflex 147 % 0x93
Otilde 148 % 0x94
Odieresis 149 % 0x95
multiply 150 % 0x96
Oslash 151 % 0x97
Ugrave 152 % 0x98
Uacute 153 % 0x99
Ucircumflex 154 % 0x9a
Udieresis 155 % 0x9b
Yacute 156 % 0x9c
Thorn 157 % 0x9d
germandbls 158 % 0x9e
agrave 159 % 0x9f
aacute 160 % 0xa0
acircumflex 161 % 0xa1
atilde 162 % 0xa2
adieresis 163 % 0xa3
aring 164 % 0xa4
ae 165 % 0xa5
ccedilla 166 % 0xa6
egrave 167 % 0xa7
eacute 168 % 0xa8
ecircumflex 169 % 0xa9
edieresis 170 % 0xaa
igrave 171 % 0xab
iacute 172 % 0xac
icircumflex 173 % 0xad
idieresis 174 % 0xae
eth 175 % 0xaf
ntilde 176 % 0xb0
ograve 177 % 0xb1
oacute 178 % 0xb2
ocircumflex 179 % 0xb3
otilde 180 % 0xb4
odieresis 181 % 0xb5
divide 182 % 0xb6
oslash 183 % 0xb7
ugrave 184 % 0xb8
uacute 185 % 0xb9
ucircumflex 186 % 0xba
udieresis 187 % 0xbb
yacute 188 % 0xbc
thorn 189 % 0xbd
ydieresis 190 % 0xbe
Amacron 191 % 0xbf
amacron 192 % 0xc0
Abreve 193 % 0xc1
abreve 194 % 0xc2
Aogonek 195 % 0xc3
aogonek 196 % 0xc4
Cacute 197 % 0xc5
cacute 198 % 0xc6
Ccircumflex 199 % 0xc7
ccircumflex 200 % 0xc8
Cdotaccent 201 % 0xc9
cdotaccent 202 % 0xca
Ccaron 203 % 0xcb
ccaron 204 % 0xcc
Dcaron 205 % 0xcd
dcaron 206 % 0xce
Dcroat 207 % 0xcf
dcroat 208 % 0xd0
Emacron 209 % 0xd1
emacron 210 % 0xd2
Ebreve 211 % 0xd3
ebreve 212 % 0xd4
Edotaccent 213 % 0xd5
edotaccent 214 % 0xd6
Eogonek 215 % 0xd7
eogonek 216 % 0xd8
Ecaron 217 % 0xd9
ecaron 218 % 0xda
Gcircumflex 219 % 0xdb
gcircumflex 220 % 0xdc
Gbreve 221 % 0xdd
gbreve 222 % 0xde
Gdotaccent 223 % 0xdf
gdotaccent 224 % 0xe0
Gcommaaccent 225 % 0xe1
gcommaaccent 226 % 0xe2
Hcircumflex 227 % 0xe3
hcircumflex 228 % 0xe4
Hbar 229 % 0xe5
hbar 230 % 0xe6
Itilde 231 % 0xe7
itilde 232 % 0xe8
Imacron 233 % 0xe9
imacron 234 % 0xea
Ibreve 235 % 0xeb
ibreve 236 % 0xec
Iogonek 237 % 0xed
iogonek 238 % 0xee
Idotaccent 239 % 0xef
dotlessi 240 % 0xf0
IJ 241 % 0xf1
ij 242 % 0xf2
Jcircumflex 243 % 0xf3
jcircumflex 244 % 0xf4
Kcommaaccent 245 % 0xf5
kcommaaccent 246 % 0xf6
kgreenlandic 247 % 0xf7
Lacute 248 % 0xf8
lacute 249 % 0xf9
Lcommaaccent 250 % 0xfa
lcommaaccent 251 % 0xfb
Lcaron 252 % 0xfc
lcaron 253 % 0xfd
Ldot 254 % 0xfe
ldot 255 % 0xff
@@ -1,260 +0,0 @@
% Encoding definition for PDFlib
% t1enc1
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: glyph name index (decimal) % index (hex)
Lslash 0 % 0x00
lslash 1 % 0x01
Nacute 2 % 0x02
nacute 3 % 0x03
Ncommaaccent 4 % 0x04
ncommaaccent 5 % 0x05
Ncaron 6 % 0x06
ncaron 7 % 0x07
napostrophe 8 % 0x08
Eng 9 % 0x09
eng 10 % 0x0a
Omacron 11 % 0x0b
omacron 12 % 0x0c
Obreve 13 % 0x0d
obreve 14 % 0x0e
Ohungarumlaut 15 % 0x0f
ohungarumlaut 16 % 0x10
OE 17 % 0x11
oe 18 % 0x12
Racute 19 % 0x13
racute 20 % 0x14
Rcommaaccent 21 % 0x15
rcommaaccent 22 % 0x16
Rcaron 23 % 0x17
rcaron 24 % 0x18
Sacute 25 % 0x19
sacute 26 % 0x1a
Scircumflex 27 % 0x1b
scircumflex 28 % 0x1c
Scedilla 29 % 0x1d
scedilla 30 % 0x1e
Scaron 31 % 0x1f
scaron 32 % 0x20
Tcommaaccent 33 % 0x21
tcommaaccent 34 % 0x22
Tcaron 35 % 0x23
tcaron 36 % 0x24
Tbar 37 % 0x25
tbar 38 % 0x26
Utilde 39 % 0x27
utilde 40 % 0x28
Umacron 41 % 0x29
umacron 42 % 0x2a
Ubreve 43 % 0x2b
ubreve 44 % 0x2c
Uring 45 % 0x2d
uring 46 % 0x2e
Uhungarumlaut 47 % 0x2f
uhungarumlaut 48 % 0x30
Uogonek 49 % 0x31
uogonek 50 % 0x32
Wcircumflex 51 % 0x33
wcircumflex 52 % 0x34
Ycircumflex 53 % 0x35
ycircumflex 54 % 0x36
Ydieresis 55 % 0x37
Zacute 56 % 0x38
zacute 57 % 0x39
Zdotaccent 58 % 0x3a
zdotaccent 59 % 0x3b
Zcaron 60 % 0x3c
zcaron 61 % 0x3d
longs 62 % 0x3e
florin 63 % 0x3f
Ohorn 64 % 0x40
ohorn 65 % 0x41
Uhorn 66 % 0x42
uhorn 67 % 0x43
Gcaron 68 % 0x44
gcaron 69 % 0x45
Aringacute 70 % 0x46
aringacute 71 % 0x47
AEacute 72 % 0x48
aeacute 73 % 0x49
Oslashacute 74 % 0x4a
oslashacute 75 % 0x4b
Scommaaccent 76 % 0x4c
scommaaccent 77 % 0x4d
Tcommaaccent 78 % 0x4e
tcommaaccent 79 % 0x4f
afii57929 80 % 0x50
afii64937 81 % 0x51
circumflex 82 % 0x52
caron 83 % 0x53
macron 84 % 0x54
breve 85 % 0x55
dotaccent 86 % 0x56
ring 87 % 0x57
ogonek 88 % 0x58
tilde 89 % 0x59
hungarumlaut 90 % 0x5a
gravecomb 91 % 0x5b
acutecomb 92 % 0x5c
tildecomb 93 % 0x5d
hookabovecomb 94 % 0x5e
dotbelowcomb 95 % 0x5f
tonos 96 % 0x60
dieresistonos 97 % 0x61
Alphatonos 98 % 0x62
anoteleia 99 % 0x63
Epsilontonos 100 % 0x64
Etatonos 101 % 0x65
Iotatonos 102 % 0x66
Omicrontonos 103 % 0x67
Upsilontonos 104 % 0x68
Omegatonos 105 % 0x69
iotadieresistonos 106 % 0x6a
Alpha 107 % 0x6b
Beta 108 % 0x6c
Gamma 109 % 0x6d
Delta 110 % 0x6e
Epsilon 111 % 0x6f
Zeta 112 % 0x70
Eta 113 % 0x71
Theta 114 % 0x72
Iota 115 % 0x73
Kappa 116 % 0x74
Lambda 117 % 0x75
Mu 118 % 0x76
Nu 119 % 0x77
Xi 120 % 0x78
Omicron 121 % 0x79
Pi 122 % 0x7a
Rho 123 % 0x7b
Sigma 124 % 0x7c
Tau 125 % 0x7d
Upsilon 126 % 0x7e
Phi 127 % 0x7f
Chi 128 % 0x80
Psi 129 % 0x81
Omega 130 % 0x82
Iotadieresis 131 % 0x83
Upsilondieresis 132 % 0x84
alphatonos 133 % 0x85
epsilontonos 134 % 0x86
etatonos 135 % 0x87
iotatonos 136 % 0x88
upsilondieresistonos 137 % 0x89
alpha 138 % 0x8a
beta 139 % 0x8b
gamma 140 % 0x8c
delta 141 % 0x8d
epsilon 142 % 0x8e
zeta 143 % 0x8f
eta 144 % 0x90
theta 145 % 0x91
iota 146 % 0x92
kappa 147 % 0x93
lambda 148 % 0x94
mu 149 % 0x95
nu 150 % 0x96
xi 151 % 0x97
omicron 152 % 0x98
pi 153 % 0x99
rho 154 % 0x9a
sigma1 155 % 0x9b
sigma 156 % 0x9c
tau 157 % 0x9d
upsilon 158 % 0x9e
phi 159 % 0x9f
chi 160 % 0xa0
psi 161 % 0xa1
omega 162 % 0xa2
iotadieresis 163 % 0xa3
upsilondieresis 164 % 0xa4
omicrontonos 165 % 0xa5
upsilontonos 166 % 0xa6
omegatonos 167 % 0xa7
theta1 168 % 0xa8
Upsilon1 169 % 0xa9
phi1 170 % 0xaa
omega1 171 % 0xab
afii10023 172 % 0xac
afii10051 173 % 0xad
afii10052 174 % 0xae
afii10053 175 % 0xaf
afii10054 176 % 0xb0
afii10055 177 % 0xb1
afii10056 178 % 0xb2
afii10057 179 % 0xb3
afii10058 180 % 0xb4
afii10059 181 % 0xb5
afii10060 182 % 0xb6
afii10061 183 % 0xb7
afii10062 184 % 0xb8
afii10145 185 % 0xb9
afii10017 186 % 0xba
afii10018 187 % 0xbb
afii10019 188 % 0xbc
afii10020 189 % 0xbd
afii10021 190 % 0xbe
afii10022 191 % 0xbf
afii10024 192 % 0xc0
afii10025 193 % 0xc1
afii10026 194 % 0xc2
afii10027 195 % 0xc3
afii10028 196 % 0xc4
afii10029 197 % 0xc5
afii10030 198 % 0xc6
afii10031 199 % 0xc7
afii10032 200 % 0xc8
afii10033 201 % 0xc9
afii10034 202 % 0xca
afii10035 203 % 0xcb
afii10036 204 % 0xcc
afii10037 205 % 0xcd
afii10038 206 % 0xce
afii10039 207 % 0xcf
afii10040 208 % 0xd0
afii10041 209 % 0xd1
afii10042 210 % 0xd2
afii10043 211 % 0xd3
afii10044 212 % 0xd4
afii10045 213 % 0xd5
afii10046 214 % 0xd6
afii10047 215 % 0xd7
afii10048 216 % 0xd8
afii10049 217 % 0xd9
afii10065 218 % 0xda
afii10066 219 % 0xdb
afii10067 220 % 0xdc
afii10068 221 % 0xdd
afii10069 222 % 0xde
afii10070 223 % 0xdf
afii10072 224 % 0xe0
afii10073 225 % 0xe1
afii10074 226 % 0xe2
afii10075 227 % 0xe3
afii10076 228 % 0xe4
afii10077 229 % 0xe5
afii10078 230 % 0xe6
afii10079 231 % 0xe7
afii10080 232 % 0xe8
afii10081 233 % 0xe9
afii10082 234 % 0xea
afii10083 235 % 0xeb
afii10084 236 % 0xec
afii10085 237 % 0xed
afii10086 238 % 0xee
afii10087 239 % 0xef
afii10088 240 % 0xf0
afii10089 241 % 0xf1
afii10090 242 % 0xf2
afii10091 243 % 0xf3
afii10092 244 % 0xf4
afii10093 245 % 0xf5
afii10094 246 % 0xf6
afii10095 247 % 0xf7
afii10096 248 % 0xf8
afii10097 249 % 0xf9
afii10071 250 % 0xfa
afii10099 251 % 0xfb
afii10100 252 % 0xfc
afii10101 253 % 0xfd
afii10102 254 % 0xfe
afii10103 255 % 0xff
@@ -1,260 +0,0 @@
% Encoding definition for PDFlib
% t1enc2
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: glyph name index (decimal) % index (hex)
afii10104 0 % 0x00
afii10105 1 % 0x01
afii10106 2 % 0x02
afii10107 3 % 0x03
afii10108 4 % 0x04
afii10109 5 % 0x05
afii10110 6 % 0x06
afii10193 7 % 0x07
afii10146 8 % 0x08
afii10194 9 % 0x09
afii10147 10 % 0x0a
afii10195 11 % 0x0b
afii10148 12 % 0x0c
afii10196 13 % 0x0d
afii10050 14 % 0x0e
afii10098 15 % 0x0f
afii10846 16 % 0x10
afii57799 17 % 0x11
afii57801 18 % 0x12
afii57800 19 % 0x13
afii57802 20 % 0x14
afii57793 21 % 0x15
afii57794 22 % 0x16
afii57795 23 % 0x17
afii57798 24 % 0x18
afii57797 25 % 0x19
afii57806 26 % 0x1a
afii57796 27 % 0x1b
afii57807 28 % 0x1c
afii57839 29 % 0x1d
afii57645 30 % 0x1e
afii57841 31 % 0x1f
afii57842 32 % 0x20
afii57804 33 % 0x21
afii57803 34 % 0x22
afii57658 35 % 0x23
afii57664 36 % 0x24
afii57665 37 % 0x25
afii57666 38 % 0x26
afii57667 39 % 0x27
afii57668 40 % 0x28
afii57669 41 % 0x29
afii57670 42 % 0x2a
afii57671 43 % 0x2b
afii57672 44 % 0x2c
afii57673 45 % 0x2d
afii57674 46 % 0x2e
afii57675 47 % 0x2f
afii57676 48 % 0x30
afii57677 49 % 0x31
afii57678 50 % 0x32
afii57679 51 % 0x33
afii57680 52 % 0x34
afii57681 53 % 0x35
afii57682 54 % 0x36
afii57683 55 % 0x37
afii57684 56 % 0x38
afii57685 57 % 0x39
afii57686 58 % 0x3a
afii57687 59 % 0x3b
afii57688 60 % 0x3c
afii57689 61 % 0x3d
afii57690 62 % 0x3e
afii57716 63 % 0x3f
afii57717 64 % 0x40
afii57718 65 % 0x41
afii57388 66 % 0x42
afii57403 67 % 0x43
afii57407 68 % 0x44
afii57409 69 % 0x45
afii57410 70 % 0x46
afii57411 71 % 0x47
afii57412 72 % 0x48
afii57413 73 % 0x49
afii57414 74 % 0x4a
afii57415 75 % 0x4b
afii57416 76 % 0x4c
afii57417 77 % 0x4d
afii57418 78 % 0x4e
afii57419 79 % 0x4f
afii57420 80 % 0x50
afii57421 81 % 0x51
afii57422 82 % 0x52
afii57423 83 % 0x53
afii57424 84 % 0x54
afii57425 85 % 0x55
afii57426 86 % 0x56
afii57427 87 % 0x57
afii57428 88 % 0x58
afii57429 89 % 0x59
afii57430 90 % 0x5a
afii57431 91 % 0x5b
afii57432 92 % 0x5c
afii57433 93 % 0x5d
afii57434 94 % 0x5e
afii57440 95 % 0x5f
afii57441 96 % 0x60
afii57442 97 % 0x61
afii57443 98 % 0x62
afii57444 99 % 0x63
afii57445 100 % 0x64
afii57446 101 % 0x65
afii57470 102 % 0x66
afii57448 103 % 0x67
afii57449 104 % 0x68
afii57450 105 % 0x69
afii57451 106 % 0x6a
afii57452 107 % 0x6b
afii57453 108 % 0x6c
afii57454 109 % 0x6d
afii57455 110 % 0x6e
afii57456 111 % 0x6f
afii57457 112 % 0x70
afii57458 113 % 0x71
afii57392 114 % 0x72
afii57393 115 % 0x73
afii57394 116 % 0x74
afii57395 117 % 0x75
afii57396 118 % 0x76
afii57397 119 % 0x77
afii57398 120 % 0x78
afii57399 121 % 0x79
afii57400 122 % 0x7a
afii57401 123 % 0x7b
afii57381 124 % 0x7c
afii63167 125 % 0x7d
afii57511 126 % 0x7e
afii57506 127 % 0x7f
afii57507 128 % 0x80
afii57512 129 % 0x81
afii57513 130 % 0x82
afii57508 131 % 0x83
afii57505 132 % 0x84
afii57509 133 % 0x85
afii57514 134 % 0x86
afii57519 135 % 0x87
afii57534 136 % 0x88
Wgrave 137 % 0x89
wgrave 138 % 0x8a
Wacute 139 % 0x8b
wacute 140 % 0x8c
Wdieresis 141 % 0x8d
wdieresis 142 % 0x8e
Ygrave 143 % 0x8f
ygrave 144 % 0x90
afii61664 145 % 0x91
afii301 146 % 0x92
afii299 147 % 0x93
afii300 148 % 0x94
figuredash 149 % 0x95
endash 150 % 0x96
emdash 151 % 0x97
afii00208 152 % 0x98
underscoredbl 153 % 0x99
quoteleft 154 % 0x9a
quoteright 155 % 0x9b
quotesinglbase 156 % 0x9c
quotereversed 157 % 0x9d
quotedblleft 158 % 0x9e
quotedblright 159 % 0x9f
quotedblbase 160 % 0xa0
dagger 161 % 0xa1
daggerdbl 162 % 0xa2
bullet 163 % 0xa3
onedotenleader 164 % 0xa4
twodotenleader 165 % 0xa5
ellipsis 166 % 0xa6
afii61573 167 % 0xa7
afii61574 168 % 0xa8
afii61575 169 % 0xa9
perthousand 170 % 0xaa
minute 171 % 0xab
second 172 % 0xac
guilsinglleft 173 % 0xad
guilsinglright 174 % 0xae
exclamdbl 175 % 0xaf
fraction 176 % 0xb0
zerosuperior 177 % 0xb1
foursuperior 178 % 0xb2
fivesuperior 179 % 0xb3
sixsuperior 180 % 0xb4
sevensuperior 181 % 0xb5
eightsuperior 182 % 0xb6
ninesuperior 183 % 0xb7
parenleftsuperior 184 % 0xb8
parenrightsuperior 185 % 0xb9
nsuperior 186 % 0xba
zeroinferior 187 % 0xbb
oneinferior 188 % 0xbc
twoinferior 189 % 0xbd
threeinferior 190 % 0xbe
fourinferior 191 % 0xbf
fiveinferior 192 % 0xc0
sixinferior 193 % 0xc1
seveninferior 194 % 0xc2
eightinferior 195 % 0xc3
nineinferior 196 % 0xc4
parenleftinferior 197 % 0xc5
parenrightinferior 198 % 0xc6
colonmonetary 199 % 0xc7
franc 200 % 0xc8
lira 201 % 0xc9
peseta 202 % 0xca
afii57636 203 % 0xcb
dong 204 % 0xcc
Euro 205 % 0xcd
afii61248 206 % 0xce
Ifraktur 207 % 0xcf
afii61289 208 % 0xd0
afii61352 209 % 0xd1
weierstrass 210 % 0xd2
Rfraktur 211 % 0xd3
prescription 212 % 0xd4
trademark 213 % 0xd5
Omega 214 % 0xd6
estimated 215 % 0xd7
aleph 216 % 0xd8
onethird 217 % 0xd9
twothirds 218 % 0xda
oneeighth 219 % 0xdb
threeeighths 220 % 0xdc
fiveeighths 221 % 0xdd
seveneighths 222 % 0xde
arrowleft 223 % 0xdf
arrowup 224 % 0xe0
arrowright 225 % 0xe1
arrowdown 226 % 0xe2
arrowboth 227 % 0xe3
arrowupdn 228 % 0xe4
arrowupdnbse 229 % 0xe5
carriagereturn 230 % 0xe6
arrowdblleft 231 % 0xe7
arrowdblup 232 % 0xe8
arrowdblright 233 % 0xe9
arrowdbldown 234 % 0xea
arrowdblboth 235 % 0xeb
universal 236 % 0xec
partialdiff 237 % 0xed
existential 238 % 0xee
emptyset 239 % 0xef
Delta 240 % 0xf0
gradient 241 % 0xf1
element 242 % 0xf2
notelement 243 % 0xf3
suchthat 244 % 0xf4
product 245 % 0xf5
summation 246 % 0xf6
minus 247 % 0xf7
fraction 248 % 0xf8
asteriskmath 249 % 0xf9
periodcentered 250 % 0xfa
radical 251 % 0xfb
proportional 252 % 0xfc
infinity 253 % 0xfd
orthogonal 254 % 0xfe
angle 255 % 0xff
@@ -1,260 +0,0 @@
% Encoding definition for PDFlib
% t1enc3
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: glyph name index (decimal) % index (hex)
logicaland 0 % 0x00
logicalor 1 % 0x01
intersection 2 % 0x02
union 3 % 0x03
integral 4 % 0x04
therefore 5 % 0x05
similar 6 % 0x06
congruent 7 % 0x07
approxequal 8 % 0x08
notequal 9 % 0x09
equivalence 10 % 0x0a
lessequal 11 % 0x0b
greaterequal 12 % 0x0c
propersubset 13 % 0x0d
propersuperset 14 % 0x0e
notsubset 15 % 0x0f
reflexsubset 16 % 0x10
reflexsuperset 17 % 0x11
circleplus 18 % 0x12
circlemultiply 19 % 0x13
perpendicular 20 % 0x14
dotmath 21 % 0x15
house 22 % 0x16
revlogicalnot 23 % 0x17
integraltp 24 % 0x18
integralbt 25 % 0x19
angleleft 26 % 0x1a
angleright 27 % 0x1b
SF100000 28 % 0x1c
SF110000 29 % 0x1d
SF010000 30 % 0x1e
SF030000 31 % 0x1f
SF020000 32 % 0x20
SF040000 33 % 0x21
SF080000 34 % 0x22
SF090000 35 % 0x23
SF060000 36 % 0x24
SF070000 37 % 0x25
SF050000 38 % 0x26
SF430000 39 % 0x27
SF240000 40 % 0x28
SF510000 41 % 0x29
SF520000 42 % 0x2a
SF390000 43 % 0x2b
SF220000 44 % 0x2c
SF210000 45 % 0x2d
SF250000 46 % 0x2e
SF500000 47 % 0x2f
SF490000 48 % 0x30
SF380000 49 % 0x31
SF280000 50 % 0x32
SF270000 51 % 0x33
SF260000 52 % 0x34
SF360000 53 % 0x35
SF370000 54 % 0x36
SF420000 55 % 0x37
SF190000 56 % 0x38
SF200000 57 % 0x39
SF230000 58 % 0x3a
SF470000 59 % 0x3b
SF480000 60 % 0x3c
SF410000 61 % 0x3d
SF450000 62 % 0x3e
SF460000 63 % 0x3f
SF400000 64 % 0x40
SF540000 65 % 0x41
SF530000 66 % 0x42
SF440000 67 % 0x43
upblock 68 % 0x44
dnblock 69 % 0x45
block 70 % 0x46
lfblock 71 % 0x47
rtblock 72 % 0x48
ltshade 73 % 0x49
shade 74 % 0x4a
dkshade 75 % 0x4b
filledbox 76 % 0x4c
H22073 77 % 0x4d
H18543 78 % 0x4e
H18551 79 % 0x4f
filledrect 80 % 0x50
triagup 81 % 0x51
triagrt 82 % 0x52
triagdn 83 % 0x53
triaglf 84 % 0x54
lozenge 85 % 0x55
circle 86 % 0x56
H18533 87 % 0x57
invbullet 88 % 0x58
invcircle 89 % 0x59
openbullet 90 % 0x5a
smileface 91 % 0x5b
invsmileface 92 % 0x5c
sun 93 % 0x5d
female 94 % 0x5e
male 95 % 0x5f
spade 96 % 0x60
club 97 % 0x61
heart 98 % 0x62
diamond 99 % 0x63
musicalnote 100 % 0x64
musicalnotedbl 101 % 0x65
dotlessj 102 % 0x66
LL 103 % 0x67
ll 104 % 0x68
Scedilla 105 % 0x69
scedilla 106 % 0x6a
commaaccent 107 % 0x6b
afii10063 108 % 0x6c
afii10064 109 % 0x6d
afii10192 110 % 0x6e
afii10831 111 % 0x6f
afii10832 112 % 0x70
Acute 113 % 0x71
Caron 114 % 0x72
Dieresis 115 % 0x73
DieresisAcute 116 % 0x74
DieresisGrave 117 % 0x75
Grave 118 % 0x76
Hungarumlaut 119 % 0x77
Macron 120 % 0x78
cyrBreve 121 % 0x79
cyrFlex 122 % 0x7a
dblGrave 123 % 0x7b
cyrbreve 124 % 0x7c
cyrflex 125 % 0x7d
dblgrave 126 % 0x7e
dieresisacute 127 % 0x7f
dieresisgrave 128 % 0x80
copyrightserif 129 % 0x81
registerserif 130 % 0x82
trademarkserif 131 % 0x83
onefitted 132 % 0x84
rupiah 133 % 0x85
threequartersemdash 134 % 0x86
centinferior 135 % 0x87
centsuperior 136 % 0x88
commainferior 137 % 0x89
commasuperior 138 % 0x8a
dollarinferior 139 % 0x8b
dollarsuperior 140 % 0x8c
hypheninferior 141 % 0x8d
hyphensuperior 142 % 0x8e
periodinferior 143 % 0x8f
periodsuperior 144 % 0x90
asuperior 145 % 0x91
bsuperior 146 % 0x92
dsuperior 147 % 0x93
esuperior 148 % 0x94
isuperior 149 % 0x95
lsuperior 150 % 0x96
msuperior 151 % 0x97
osuperior 152 % 0x98
rsuperior 153 % 0x99
ssuperior 154 % 0x9a
tsuperior 155 % 0x9b
Brevesmall 156 % 0x9c
Caronsmall 157 % 0x9d
Circumflexsmall 158 % 0x9e
Dotaccentsmall 159 % 0x9f
Hungarumlautsmall 160 % 0xa0
Lslashsmall 161 % 0xa1
OEsmall 162 % 0xa2
Ogoneksmall 163 % 0xa3
Ringsmall 164 % 0xa4
Scaronsmall 165 % 0xa5
Tildesmall 166 % 0xa6
Zcaronsmall 167 % 0xa7
exclamsmall 168 % 0xa8
dollaroldstyle 169 % 0xa9
ampersandsmall 170 % 0xaa
zerooldstyle 171 % 0xab
oneoldstyle 172 % 0xac
twooldstyle 173 % 0xad
threeoldstyle 174 % 0xae
fouroldstyle 175 % 0xaf
fiveoldstyle 176 % 0xb0
sixoldstyle 177 % 0xb1
sevenoldstyle 178 % 0xb2
eightoldstyle 179 % 0xb3
nineoldstyle 180 % 0xb4
questionsmall 181 % 0xb5
Gravesmall 182 % 0xb6
Asmall 183 % 0xb7
Bsmall 184 % 0xb8
Csmall 185 % 0xb9
Dsmall 186 % 0xba
Esmall 187 % 0xbb
Fsmall 188 % 0xbc
Gsmall 189 % 0xbd
Hsmall 190 % 0xbe
Ismall 191 % 0xbf
Jsmall 192 % 0xc0
Ksmall 193 % 0xc1
Lsmall 194 % 0xc2
Msmall 195 % 0xc3
Nsmall 196 % 0xc4
Osmall 197 % 0xc5
Psmall 198 % 0xc6
Qsmall 199 % 0xc7
Rsmall 200 % 0xc8
Ssmall 201 % 0xc9
Tsmall 202 % 0xca
Usmall 203 % 0xcb
Vsmall 204 % 0xcc
Wsmall 205 % 0xcd
Xsmall 206 % 0xce
Ysmall 207 % 0xcf
Zsmall 208 % 0xd0
exclamdownsmall 209 % 0xd1
centoldstyle 210 % 0xd2
Dieresissmall 211 % 0xd3
Macronsmall 212 % 0xd4
Acutesmall 213 % 0xd5
Cedillasmall 214 % 0xd6
questiondownsmall 215 % 0xd7
Agravesmall 216 % 0xd8
Aacutesmall 217 % 0xd9
Acircumflexsmall 218 % 0xda
Atildesmall 219 % 0xdb
Adieresissmall 220 % 0xdc
Aringsmall 221 % 0xdd
AEsmall 222 % 0xde
Ccedillasmall 223 % 0xdf
Egravesmall 224 % 0xe0
Eacutesmall 225 % 0xe1
Ecircumflexsmall 226 % 0xe2
Edieresissmall 227 % 0xe3
Igravesmall 228 % 0xe4
Iacutesmall 229 % 0xe5
Icircumflexsmall 230 % 0xe6
Idieresissmall 231 % 0xe7
Ethsmall 232 % 0xe8
Ntildesmall 233 % 0xe9
Ogravesmall 234 % 0xea
Oacutesmall 235 % 0xeb
Ocircumflexsmall 236 % 0xec
Otildesmall 237 % 0xed
Odieresissmall 238 % 0xee
Oslashsmall 239 % 0xef
Ugravesmall 240 % 0xf0
Uacutesmall 241 % 0xf1
Ucircumflexsmall 242 % 0xf2
Udieresissmall 243 % 0xf3
Yacutesmall 244 % 0xf4
Thornsmall 245 % 0xf5
Ydieresissmall 246 % 0xf6
radicalex 247 % 0xf7
arrowvertex 248 % 0xf8
arrowhorizex 249 % 0xf9
registersans 250 % 0xfa
copyrightsans 251 % 0xfb
trademarksans 252 % 0xfc
parenlefttp 253 % 0xfd
parenleftex 254 % 0xfe
parenleftbt 255 % 0xff
@@ -1,31 +0,0 @@
% Encoding definition for PDFlib
% t1enc4
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: glyph name index (decimal) % index (hex)
bracketlefttp 0 % 0x00
bracketleftex 1 % 0x01
bracketleftbt 2 % 0x02
bracelefttp 3 % 0x03
braceleftmid 4 % 0x04
braceleftbt 5 % 0x05
braceex 6 % 0x06
integralex 7 % 0x07
parenrighttp 8 % 0x08
parenrightex 9 % 0x09
parenrightbt 10 % 0x0a
bracketrighttp 11 % 0x0b
bracketrightex 12 % 0x0c
bracketrightbt 13 % 0x0d
bracerighttp 14 % 0x0e
bracerightmid 15 % 0x0f
bracerightbt 16 % 0x10
ff 17 % 0x11
fi 18 % 0x12
fl 19 % 0x13
ffi 20 % 0x14
ffl 21 % 0x15
afii57705 22 % 0x16
afii57694 23 % 0x17
afii57695 24 % 0x18
afii57723 25 % 0x19
afii57700 26 % 0x1a
@@ -1,260 +0,0 @@
% Encoding definition for PDFlib
% ttenc0
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: unicode (hex) index (decimal) % index (hex)
0x20 0 % 0x00
0x21 1 % 0x01
0x22 2 % 0x02
0x23 3 % 0x03
0x24 4 % 0x04
0x25 5 % 0x05
0x26 6 % 0x06
0x27 7 % 0x07
0x28 8 % 0x08
0x29 9 % 0x09
0x2a 10 % 0x0a
0x2b 11 % 0x0b
0x2c 12 % 0x0c
0x2d 13 % 0x0d
0x2e 14 % 0x0e
0x2f 15 % 0x0f
0x30 16 % 0x10
0x31 17 % 0x11
0x32 18 % 0x12
0x33 19 % 0x13
0x34 20 % 0x14
0x35 21 % 0x15
0x36 22 % 0x16
0x37 23 % 0x17
0x38 24 % 0x18
0x39 25 % 0x19
0x3a 26 % 0x1a
0x3b 27 % 0x1b
0x3c 28 % 0x1c
0x3d 29 % 0x1d
0x3e 30 % 0x1e
0x3f 31 % 0x1f
0x40 32 % 0x20
0x41 33 % 0x21
0x42 34 % 0x22
0x43 35 % 0x23
0x44 36 % 0x24
0x45 37 % 0x25
0x46 38 % 0x26
0x47 39 % 0x27
0x48 40 % 0x28
0x49 41 % 0x29
0x4a 42 % 0x2a
0x4b 43 % 0x2b
0x4c 44 % 0x2c
0x4d 45 % 0x2d
0x4e 46 % 0x2e
0x4f 47 % 0x2f
0x50 48 % 0x30
0x51 49 % 0x31
0x52 50 % 0x32
0x53 51 % 0x33
0x54 52 % 0x34
0x55 53 % 0x35
0x56 54 % 0x36
0x57 55 % 0x37
0x58 56 % 0x38
0x59 57 % 0x39
0x5a 58 % 0x3a
0x5b 59 % 0x3b
0x5c 60 % 0x3c
0x5d 61 % 0x3d
0x5e 62 % 0x3e
0x5f 63 % 0x3f
0x60 64 % 0x40
0x61 65 % 0x41
0x62 66 % 0x42
0x63 67 % 0x43
0x64 68 % 0x44
0x65 69 % 0x45
0x66 70 % 0x46
0x67 71 % 0x47
0x68 72 % 0x48
0x69 73 % 0x49
0x6a 74 % 0x4a
0x6b 75 % 0x4b
0x6c 76 % 0x4c
0x6d 77 % 0x4d
0x6e 78 % 0x4e
0x6f 79 % 0x4f
0x70 80 % 0x50
0x71 81 % 0x51
0x72 82 % 0x52
0x73 83 % 0x53
0x74 84 % 0x54
0x75 85 % 0x55
0x76 86 % 0x56
0x77 87 % 0x57
0x78 88 % 0x58
0x79 89 % 0x59
0x7a 90 % 0x5a
0x7b 91 % 0x5b
0x7c 92 % 0x5c
0x7d 93 % 0x5d
0x7e 94 % 0x5e
0xa0 95 % 0x5f
0xa1 96 % 0x60
0xa2 97 % 0x61
0xa3 98 % 0x62
0xa4 99 % 0x63
0xa5 100 % 0x64
0xa6 101 % 0x65
0xa7 102 % 0x66
0xa8 103 % 0x67
0xa9 104 % 0x68
0xaa 105 % 0x69
0xab 106 % 0x6a
0xac 107 % 0x6b
0xad 108 % 0x6c
0xae 109 % 0x6d
0xaf 110 % 0x6e
0xb0 111 % 0x6f
0xb1 112 % 0x70
0xb2 113 % 0x71
0xb3 114 % 0x72
0xb4 115 % 0x73
0xb5 116 % 0x74
0xb6 117 % 0x75
0xb7 118 % 0x76
0xb8 119 % 0x77
0xb9 120 % 0x78
0xba 121 % 0x79
0xbb 122 % 0x7a
0xbc 123 % 0x7b
0xbd 124 % 0x7c
0xbe 125 % 0x7d
0xbf 126 % 0x7e
0xc0 127 % 0x7f
0xc1 128 % 0x80
0xc2 129 % 0x81
0xc3 130 % 0x82
0xc4 131 % 0x83
0xc5 132 % 0x84
0xc6 133 % 0x85
0xc7 134 % 0x86
0xc8 135 % 0x87
0xc9 136 % 0x88
0xca 137 % 0x89
0xcb 138 % 0x8a
0xcc 139 % 0x8b
0xcd 140 % 0x8c
0xce 141 % 0x8d
0xcf 142 % 0x8e
0xd0 143 % 0x8f
0xd1 144 % 0x90
0xd2 145 % 0x91
0xd3 146 % 0x92
0xd4 147 % 0x93
0xd5 148 % 0x94
0xd6 149 % 0x95
0xd7 150 % 0x96
0xd8 151 % 0x97
0xd9 152 % 0x98
0xda 153 % 0x99
0xdb 154 % 0x9a
0xdc 155 % 0x9b
0xdd 156 % 0x9c
0xde 157 % 0x9d
0xdf 158 % 0x9e
0xe0 159 % 0x9f
0xe1 160 % 0xa0
0xe2 161 % 0xa1
0xe3 162 % 0xa2
0xe4 163 % 0xa3
0xe5 164 % 0xa4
0xe6 165 % 0xa5
0xe7 166 % 0xa6
0xe8 167 % 0xa7
0xe9 168 % 0xa8
0xea 169 % 0xa9
0xeb 170 % 0xaa
0xec 171 % 0xab
0xed 172 % 0xac
0xee 173 % 0xad
0xef 174 % 0xae
0xf0 175 % 0xaf
0xf1 176 % 0xb0
0xf2 177 % 0xb1
0xf3 178 % 0xb2
0xf4 179 % 0xb3
0xf5 180 % 0xb4
0xf6 181 % 0xb5
0xf7 182 % 0xb6
0xf8 183 % 0xb7
0xf9 184 % 0xb8
0xfa 185 % 0xb9
0xfb 186 % 0xba
0xfc 187 % 0xbb
0xfd 188 % 0xbc
0xfe 189 % 0xbd
0xff 190 % 0xbe
0x100 191 % 0xbf
0x101 192 % 0xc0
0x102 193 % 0xc1
0x103 194 % 0xc2
0x104 195 % 0xc3
0x105 196 % 0xc4
0x106 197 % 0xc5
0x107 198 % 0xc6
0x108 199 % 0xc7
0x109 200 % 0xc8
0x10a 201 % 0xc9
0x10b 202 % 0xca
0x10c 203 % 0xcb
0x10d 204 % 0xcc
0x10e 205 % 0xcd
0x10f 206 % 0xce
0x110 207 % 0xcf
0x111 208 % 0xd0
0x112 209 % 0xd1
0x113 210 % 0xd2
0x114 211 % 0xd3
0x115 212 % 0xd4
0x116 213 % 0xd5
0x117 214 % 0xd6
0x118 215 % 0xd7
0x119 216 % 0xd8
0x11a 217 % 0xd9
0x11b 218 % 0xda
0x11c 219 % 0xdb
0x11d 220 % 0xdc
0x11e 221 % 0xdd
0x11f 222 % 0xde
0x120 223 % 0xdf
0x121 224 % 0xe0
0x122 225 % 0xe1
0x123 226 % 0xe2
0x124 227 % 0xe3
0x125 228 % 0xe4
0x126 229 % 0xe5
0x127 230 % 0xe6
0x128 231 % 0xe7
0x129 232 % 0xe8
0x12a 233 % 0xe9
0x12b 234 % 0xea
0x12c 235 % 0xeb
0x12d 236 % 0xec
0x12e 237 % 0xed
0x12f 238 % 0xee
0x130 239 % 0xef
0x131 240 % 0xf0
0x132 241 % 0xf1
0x133 242 % 0xf2
0x134 243 % 0xf3
0x135 244 % 0xf4
0x136 245 % 0xf5
0x137 246 % 0xf6
0x138 247 % 0xf7
0x139 248 % 0xf8
0x13a 249 % 0xf9
0x13b 250 % 0xfa
0x13c 251 % 0xfb
0x13d 252 % 0xfc
0x13e 253 % 0xfd
0x13f 254 % 0xfe
0x140 255 % 0xff
@@ -1,260 +0,0 @@
% Encoding definition for PDFlib
% ttenc1
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: unicode (hex) index (decimal) % index (hex)
0x141 0 % 0x00
0x142 1 % 0x01
0x143 2 % 0x02
0x144 3 % 0x03
0x145 4 % 0x04
0x146 5 % 0x05
0x147 6 % 0x06
0x148 7 % 0x07
0x149 8 % 0x08
0x14a 9 % 0x09
0x14b 10 % 0x0a
0x14c 11 % 0x0b
0x14d 12 % 0x0c
0x14e 13 % 0x0d
0x14f 14 % 0x0e
0x150 15 % 0x0f
0x151 16 % 0x10
0x152 17 % 0x11
0x153 18 % 0x12
0x154 19 % 0x13
0x155 20 % 0x14
0x156 21 % 0x15
0x157 22 % 0x16
0x158 23 % 0x17
0x159 24 % 0x18
0x15a 25 % 0x19
0x15b 26 % 0x1a
0x15c 27 % 0x1b
0x15d 28 % 0x1c
0x15e 29 % 0x1d
0x15f 30 % 0x1e
0x160 31 % 0x1f
0x161 32 % 0x20
0x162 33 % 0x21
0x163 34 % 0x22
0x164 35 % 0x23
0x165 36 % 0x24
0x166 37 % 0x25
0x167 38 % 0x26
0x168 39 % 0x27
0x169 40 % 0x28
0x16a 41 % 0x29
0x16b 42 % 0x2a
0x16c 43 % 0x2b
0x16d 44 % 0x2c
0x16e 45 % 0x2d
0x16f 46 % 0x2e
0x170 47 % 0x2f
0x171 48 % 0x30
0x172 49 % 0x31
0x173 50 % 0x32
0x174 51 % 0x33
0x175 52 % 0x34
0x176 53 % 0x35
0x177 54 % 0x36
0x178 55 % 0x37
0x179 56 % 0x38
0x17a 57 % 0x39
0x17b 58 % 0x3a
0x17c 59 % 0x3b
0x17d 60 % 0x3c
0x17e 61 % 0x3d
0x17f 62 % 0x3e
0x192 63 % 0x3f
0x1a0 64 % 0x40
0x1a1 65 % 0x41
0x1af 66 % 0x42
0x1b0 67 % 0x43
0x1e6 68 % 0x44
0x1e7 69 % 0x45
0x1fa 70 % 0x46
0x1fb 71 % 0x47
0x1fc 72 % 0x48
0x1fd 73 % 0x49
0x1fe 74 % 0x4a
0x1ff 75 % 0x4b
0x218 76 % 0x4c
0x219 77 % 0x4d
0x21a 78 % 0x4e
0x21b 79 % 0x4f
0x2bc 80 % 0x50
0x2bd 81 % 0x51
0x2c6 82 % 0x52
0x2c7 83 % 0x53
0x2c9 84 % 0x54
0x2d8 85 % 0x55
0x2d9 86 % 0x56
0x2da 87 % 0x57
0x2db 88 % 0x58
0x2dc 89 % 0x59
0x2dd 90 % 0x5a
0x300 91 % 0x5b
0x301 92 % 0x5c
0x303 93 % 0x5d
0x309 94 % 0x5e
0x323 95 % 0x5f
0x384 96 % 0x60
0x385 97 % 0x61
0x386 98 % 0x62
0x387 99 % 0x63
0x388 100 % 0x64
0x389 101 % 0x65
0x38a 102 % 0x66
0x38c 103 % 0x67
0x38e 104 % 0x68
0x38f 105 % 0x69
0x390 106 % 0x6a
0x391 107 % 0x6b
0x392 108 % 0x6c
0x393 109 % 0x6d
0x394 110 % 0x6e
0x395 111 % 0x6f
0x396 112 % 0x70
0x397 113 % 0x71
0x398 114 % 0x72
0x399 115 % 0x73
0x39a 116 % 0x74
0x39b 117 % 0x75
0x39c 118 % 0x76
0x39d 119 % 0x77
0x39e 120 % 0x78
0x39f 121 % 0x79
0x3a0 122 % 0x7a
0x3a1 123 % 0x7b
0x3a3 124 % 0x7c
0x3a4 125 % 0x7d
0x3a5 126 % 0x7e
0x3a6 127 % 0x7f
0x3a7 128 % 0x80
0x3a8 129 % 0x81
0x3a9 130 % 0x82
0x3aa 131 % 0x83
0x3ab 132 % 0x84
0x3ac 133 % 0x85
0x3ad 134 % 0x86
0x3ae 135 % 0x87
0x3af 136 % 0x88
0x3b0 137 % 0x89
0x3b1 138 % 0x8a
0x3b2 139 % 0x8b
0x3b3 140 % 0x8c
0x3b4 141 % 0x8d
0x3b5 142 % 0x8e
0x3b6 143 % 0x8f
0x3b7 144 % 0x90
0x3b8 145 % 0x91
0x3b9 146 % 0x92
0x3ba 147 % 0x93
0x3bb 148 % 0x94
0x3bc 149 % 0x95
0x3bd 150 % 0x96
0x3be 151 % 0x97
0x3bf 152 % 0x98
0x3c0 153 % 0x99
0x3c1 154 % 0x9a
0x3c2 155 % 0x9b
0x3c3 156 % 0x9c
0x3c4 157 % 0x9d
0x3c5 158 % 0x9e
0x3c6 159 % 0x9f
0x3c7 160 % 0xa0
0x3c8 161 % 0xa1
0x3c9 162 % 0xa2
0x3ca 163 % 0xa3
0x3cb 164 % 0xa4
0x3cc 165 % 0xa5
0x3cd 166 % 0xa6
0x3ce 167 % 0xa7
0x3d1 168 % 0xa8
0x3d2 169 % 0xa9
0x3d5 170 % 0xaa
0x3d6 171 % 0xab
0x401 172 % 0xac
0x402 173 % 0xad
0x403 174 % 0xae
0x404 175 % 0xaf
0x405 176 % 0xb0
0x406 177 % 0xb1
0x407 178 % 0xb2
0x408 179 % 0xb3
0x409 180 % 0xb4
0x40a 181 % 0xb5
0x40b 182 % 0xb6
0x40c 183 % 0xb7
0x40e 184 % 0xb8
0x40f 185 % 0xb9
0x410 186 % 0xba
0x411 187 % 0xbb
0x412 188 % 0xbc
0x413 189 % 0xbd
0x414 190 % 0xbe
0x415 191 % 0xbf
0x416 192 % 0xc0
0x417 193 % 0xc1
0x418 194 % 0xc2
0x419 195 % 0xc3
0x41a 196 % 0xc4
0x41b 197 % 0xc5
0x41c 198 % 0xc6
0x41d 199 % 0xc7
0x41e 200 % 0xc8
0x41f 201 % 0xc9
0x420 202 % 0xca
0x421 203 % 0xcb
0x422 204 % 0xcc
0x423 205 % 0xcd
0x424 206 % 0xce
0x425 207 % 0xcf
0x426 208 % 0xd0
0x427 209 % 0xd1
0x428 210 % 0xd2
0x429 211 % 0xd3
0x42a 212 % 0xd4
0x42b 213 % 0xd5
0x42c 214 % 0xd6
0x42d 215 % 0xd7
0x42e 216 % 0xd8
0x42f 217 % 0xd9
0x430 218 % 0xda
0x431 219 % 0xdb
0x432 220 % 0xdc
0x433 221 % 0xdd
0x434 222 % 0xde
0x435 223 % 0xdf
0x436 224 % 0xe0
0x437 225 % 0xe1
0x438 226 % 0xe2
0x439 227 % 0xe3
0x43a 228 % 0xe4
0x43b 229 % 0xe5
0x43c 230 % 0xe6
0x43d 231 % 0xe7
0x43e 232 % 0xe8
0x43f 233 % 0xe9
0x440 234 % 0xea
0x441 235 % 0xeb
0x442 236 % 0xec
0x443 237 % 0xed
0x444 238 % 0xee
0x445 239 % 0xef
0x446 240 % 0xf0
0x447 241 % 0xf1
0x448 242 % 0xf2
0x449 243 % 0xf3
0x44a 244 % 0xf4
0x44b 245 % 0xf5
0x44c 246 % 0xf6
0x44d 247 % 0xf7
0x44e 248 % 0xf8
0x44f 249 % 0xf9
0x451 250 % 0xfa
0x452 251 % 0xfb
0x453 252 % 0xfc
0x454 253 % 0xfd
0x455 254 % 0xfe
0x456 255 % 0xff
@@ -1,260 +0,0 @@
% Encoding definition for PDFlib
% ttenc2
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: unicode (hex) index (decimal) % index (hex)
0x457 0 % 0x00
0x458 1 % 0x01
0x459 2 % 0x02
0x45a 3 % 0x03
0x45b 4 % 0x04
0x45c 5 % 0x05
0x45e 6 % 0x06
0x45f 7 % 0x07
0x462 8 % 0x08
0x463 9 % 0x09
0x472 10 % 0x0a
0x473 11 % 0x0b
0x474 12 % 0x0c
0x475 13 % 0x0d
0x490 14 % 0x0e
0x491 15 % 0x0f
0x4d9 16 % 0x10
0x5b0 17 % 0x11
0x5b1 18 % 0x12
0x5b2 19 % 0x13
0x5b3 20 % 0x14
0x5b4 21 % 0x15
0x5b5 22 % 0x16
0x5b6 23 % 0x17
0x5b7 24 % 0x18
0x5b8 25 % 0x19
0x5b9 26 % 0x1a
0x5bb 27 % 0x1b
0x5bc 28 % 0x1c
0x5bd 29 % 0x1d
0x5be 30 % 0x1e
0x5bf 31 % 0x1f
0x5c0 32 % 0x20
0x5c1 33 % 0x21
0x5c2 34 % 0x22
0x5c3 35 % 0x23
0x5d0 36 % 0x24
0x5d1 37 % 0x25
0x5d2 38 % 0x26
0x5d3 39 % 0x27
0x5d4 40 % 0x28
0x5d5 41 % 0x29
0x5d6 42 % 0x2a
0x5d7 43 % 0x2b
0x5d8 44 % 0x2c
0x5d9 45 % 0x2d
0x5da 46 % 0x2e
0x5db 47 % 0x2f
0x5dc 48 % 0x30
0x5dd 49 % 0x31
0x5de 50 % 0x32
0x5df 51 % 0x33
0x5e0 52 % 0x34
0x5e1 53 % 0x35
0x5e2 54 % 0x36
0x5e3 55 % 0x37
0x5e4 56 % 0x38
0x5e5 57 % 0x39
0x5e6 58 % 0x3a
0x5e7 59 % 0x3b
0x5e8 60 % 0x3c
0x5e9 61 % 0x3d
0x5ea 62 % 0x3e
0x5f0 63 % 0x3f
0x5f1 64 % 0x40
0x5f2 65 % 0x41
0x60c 66 % 0x42
0x61b 67 % 0x43
0x61f 68 % 0x44
0x621 69 % 0x45
0x622 70 % 0x46
0x623 71 % 0x47
0x624 72 % 0x48
0x625 73 % 0x49
0x626 74 % 0x4a
0x627 75 % 0x4b
0x628 76 % 0x4c
0x629 77 % 0x4d
0x62a 78 % 0x4e
0x62b 79 % 0x4f
0x62c 80 % 0x50
0x62d 81 % 0x51
0x62e 82 % 0x52
0x62f 83 % 0x53
0x630 84 % 0x54
0x631 85 % 0x55
0x632 86 % 0x56
0x633 87 % 0x57
0x634 88 % 0x58
0x635 89 % 0x59
0x636 90 % 0x5a
0x637 91 % 0x5b
0x638 92 % 0x5c
0x639 93 % 0x5d
0x63a 94 % 0x5e
0x640 95 % 0x5f
0x641 96 % 0x60
0x642 97 % 0x61
0x643 98 % 0x62
0x644 99 % 0x63
0x645 100 % 0x64
0x646 101 % 0x65
0x647 102 % 0x66
0x648 103 % 0x67
0x649 104 % 0x68
0x64a 105 % 0x69
0x64b 106 % 0x6a
0x64c 107 % 0x6b
0x64d 108 % 0x6c
0x64e 109 % 0x6d
0x64f 110 % 0x6e
0x650 111 % 0x6f
0x651 112 % 0x70
0x652 113 % 0x71
0x660 114 % 0x72
0x661 115 % 0x73
0x662 116 % 0x74
0x663 117 % 0x75
0x664 118 % 0x76
0x665 119 % 0x77
0x666 120 % 0x78
0x667 121 % 0x79
0x668 122 % 0x7a
0x669 123 % 0x7b
0x66a 124 % 0x7c
0x66d 125 % 0x7d
0x679 126 % 0x7e
0x67e 127 % 0x7f
0x686 128 % 0x80
0x688 129 % 0x81
0x691 130 % 0x82
0x698 131 % 0x83
0x6a4 132 % 0x84
0x6af 133 % 0x85
0x6ba 134 % 0x86
0x6d2 135 % 0x87
0x6d5 136 % 0x88
0x1e80 137 % 0x89
0x1e81 138 % 0x8a
0x1e82 139 % 0x8b
0x1e83 140 % 0x8c
0x1e84 141 % 0x8d
0x1e85 142 % 0x8e
0x1ef2 143 % 0x8f
0x1ef3 144 % 0x90
0x200c 145 % 0x91
0x200d 146 % 0x92
0x200e 147 % 0x93
0x200f 148 % 0x94
0x2012 149 % 0x95
0x2013 150 % 0x96
0x2014 151 % 0x97
0x2015 152 % 0x98
0x2017 153 % 0x99
0x2018 154 % 0x9a
0x2019 155 % 0x9b
0x201a 156 % 0x9c
0x201b 157 % 0x9d
0x201c 158 % 0x9e
0x201d 159 % 0x9f
0x201e 160 % 0xa0
0x2020 161 % 0xa1
0x2021 162 % 0xa2
0x2022 163 % 0xa3
0x2024 164 % 0xa4
0x2025 165 % 0xa5
0x2026 166 % 0xa6
0x202c 167 % 0xa7
0x202d 168 % 0xa8
0x202e 169 % 0xa9
0x2030 170 % 0xaa
0x2032 171 % 0xab
0x2033 172 % 0xac
0x2039 173 % 0xad
0x203a 174 % 0xae
0x203c 175 % 0xaf
0x2044 176 % 0xb0
0x2070 177 % 0xb1
0x2074 178 % 0xb2
0x2075 179 % 0xb3
0x2076 180 % 0xb4
0x2077 181 % 0xb5
0x2078 182 % 0xb6
0x2079 183 % 0xb7
0x207d 184 % 0xb8
0x207e 185 % 0xb9
0x207f 186 % 0xba
0x2080 187 % 0xbb
0x2081 188 % 0xbc
0x2082 189 % 0xbd
0x2083 190 % 0xbe
0x2084 191 % 0xbf
0x2085 192 % 0xc0
0x2086 193 % 0xc1
0x2087 194 % 0xc2
0x2088 195 % 0xc3
0x2089 196 % 0xc4
0x208d 197 % 0xc5
0x208e 198 % 0xc6
0x20a1 199 % 0xc7
0x20a3 200 % 0xc8
0x20a4 201 % 0xc9
0x20a7 202 % 0xca
0x20aa 203 % 0xcb
0x20ab 204 % 0xcc
0x20ac 205 % 0xcd
0x2105 206 % 0xce
0x2111 207 % 0xcf
0x2113 208 % 0xd0
0x2116 209 % 0xd1
0x2118 210 % 0xd2
0x211c 211 % 0xd3
0x211e 212 % 0xd4
0x2122 213 % 0xd5
0x2126 214 % 0xd6
0x212e 215 % 0xd7
0x2135 216 % 0xd8
0x2153 217 % 0xd9
0x2154 218 % 0xda
0x215b 219 % 0xdb
0x215c 220 % 0xdc
0x215d 221 % 0xdd
0x215e 222 % 0xde
0x2190 223 % 0xdf
0x2191 224 % 0xe0
0x2192 225 % 0xe1
0x2193 226 % 0xe2
0x2194 227 % 0xe3
0x2195 228 % 0xe4
0x21a8 229 % 0xe5
0x21b5 230 % 0xe6
0x21d0 231 % 0xe7
0x21d1 232 % 0xe8
0x21d2 233 % 0xe9
0x21d3 234 % 0xea
0x21d4 235 % 0xeb
0x2200 236 % 0xec
0x2202 237 % 0xed
0x2203 238 % 0xee
0x2205 239 % 0xef
0x2206 240 % 0xf0
0x2207 241 % 0xf1
0x2208 242 % 0xf2
0x2209 243 % 0xf3
0x220b 244 % 0xf4
0x220f 245 % 0xf5
0x2211 246 % 0xf6
0x2212 247 % 0xf7
0x2215 248 % 0xf8
0x2217 249 % 0xf9
0x2219 250 % 0xfa
0x221a 251 % 0xfb
0x221d 252 % 0xfc
0x221e 253 % 0xfd
0x221f 254 % 0xfe
0x2220 255 % 0xff
@@ -1,260 +0,0 @@
% Encoding definition for PDFlib
% ttenc3
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: unicode (hex) index (decimal) % index (hex)
0x2227 0 % 0x00
0x2228 1 % 0x01
0x2229 2 % 0x02
0x222a 3 % 0x03
0x222b 4 % 0x04
0x2234 5 % 0x05
0x223c 6 % 0x06
0x2245 7 % 0x07
0x2248 8 % 0x08
0x2260 9 % 0x09
0x2261 10 % 0x0a
0x2264 11 % 0x0b
0x2265 12 % 0x0c
0x2282 13 % 0x0d
0x2283 14 % 0x0e
0x2284 15 % 0x0f
0x2286 16 % 0x10
0x2287 17 % 0x11
0x2295 18 % 0x12
0x2297 19 % 0x13
0x22a5 20 % 0x14
0x22c5 21 % 0x15
0x2302 22 % 0x16
0x2310 23 % 0x17
0x2320 24 % 0x18
0x2321 25 % 0x19
0x2329 26 % 0x1a
0x232a 27 % 0x1b
0x2500 28 % 0x1c
0x2502 29 % 0x1d
0x250c 30 % 0x1e
0x2510 31 % 0x1f
0x2514 32 % 0x20
0x2518 33 % 0x21
0x251c 34 % 0x22
0x2524 35 % 0x23
0x252c 36 % 0x24
0x2534 37 % 0x25
0x253c 38 % 0x26
0x2550 39 % 0x27
0x2551 40 % 0x28
0x2552 41 % 0x29
0x2553 42 % 0x2a
0x2554 43 % 0x2b
0x2555 44 % 0x2c
0x2556 45 % 0x2d
0x2557 46 % 0x2e
0x2558 47 % 0x2f
0x2559 48 % 0x30
0x255a 49 % 0x31
0x255b 50 % 0x32
0x255c 51 % 0x33
0x255d 52 % 0x34
0x255e 53 % 0x35
0x255f 54 % 0x36
0x2560 55 % 0x37
0x2561 56 % 0x38
0x2562 57 % 0x39
0x2563 58 % 0x3a
0x2564 59 % 0x3b
0x2565 60 % 0x3c
0x2566 61 % 0x3d
0x2567 62 % 0x3e
0x2568 63 % 0x3f
0x2569 64 % 0x40
0x256a 65 % 0x41
0x256b 66 % 0x42
0x256c 67 % 0x43
0x2580 68 % 0x44
0x2584 69 % 0x45
0x2588 70 % 0x46
0x258c 71 % 0x47
0x2590 72 % 0x48
0x2591 73 % 0x49
0x2592 74 % 0x4a
0x2593 75 % 0x4b
0x25a0 76 % 0x4c
0x25a1 77 % 0x4d
0x25aa 78 % 0x4e
0x25ab 79 % 0x4f
0x25ac 80 % 0x50
0x25b2 81 % 0x51
0x25ba 82 % 0x52
0x25bc 83 % 0x53
0x25c4 84 % 0x54
0x25ca 85 % 0x55
0x25cb 86 % 0x56
0x25cf 87 % 0x57
0x25d8 88 % 0x58
0x25d9 89 % 0x59
0x25e6 90 % 0x5a
0x263a 91 % 0x5b
0x263b 92 % 0x5c
0x263c 93 % 0x5d
0x2640 94 % 0x5e
0x2642 95 % 0x5f
0x2660 96 % 0x60
0x2663 97 % 0x61
0x2665 98 % 0x62
0x2666 99 % 0x63
0x266a 100 % 0x64
0x266b 101 % 0x65
0xf6be 102 % 0x66
0xf6bf 103 % 0x67
0xf6c0 104 % 0x68
0xf6c1 105 % 0x69
0xf6c2 106 % 0x6a
0xf6c3 107 % 0x6b
0xf6c4 108 % 0x6c
0xf6c5 109 % 0x6d
0xf6c6 110 % 0x6e
0xf6c7 111 % 0x6f
0xf6c8 112 % 0x70
0xf6c9 113 % 0x71
0xf6ca 114 % 0x72
0xf6cb 115 % 0x73
0xf6cc 116 % 0x74
0xf6cd 117 % 0x75
0xf6ce 118 % 0x76
0xf6cf 119 % 0x77
0xf6d0 120 % 0x78
0xf6d1 121 % 0x79
0xf6d2 122 % 0x7a
0xf6d3 123 % 0x7b
0xf6d4 124 % 0x7c
0xf6d5 125 % 0x7d
0xf6d6 126 % 0x7e
0xf6d7 127 % 0x7f
0xf6d8 128 % 0x80
0xf6d9 129 % 0x81
0xf6da 130 % 0x82
0xf6db 131 % 0x83
0xf6dc 132 % 0x84
0xf6dd 133 % 0x85
0xf6de 134 % 0x86
0xf6df 135 % 0x87
0xf6e0 136 % 0x88
0xf6e1 137 % 0x89
0xf6e2 138 % 0x8a
0xf6e3 139 % 0x8b
0xf6e4 140 % 0x8c
0xf6e5 141 % 0x8d
0xf6e6 142 % 0x8e
0xf6e7 143 % 0x8f
0xf6e8 144 % 0x90
0xf6e9 145 % 0x91
0xf6ea 146 % 0x92
0xf6eb 147 % 0x93
0xf6ec 148 % 0x94
0xf6ed 149 % 0x95
0xf6ee 150 % 0x96
0xf6ef 151 % 0x97
0xf6f0 152 % 0x98
0xf6f1 153 % 0x99
0xf6f2 154 % 0x9a
0xf6f3 155 % 0x9b
0xf6f4 156 % 0x9c
0xf6f5 157 % 0x9d
0xf6f6 158 % 0x9e
0xf6f7 159 % 0x9f
0xf6f8 160 % 0xa0
0xf6f9 161 % 0xa1
0xf6fa 162 % 0xa2
0xf6fb 163 % 0xa3
0xf6fc 164 % 0xa4
0xf6fd 165 % 0xa5
0xf6fe 166 % 0xa6
0xf6ff 167 % 0xa7
0xf721 168 % 0xa8
0xf724 169 % 0xa9
0xf726 170 % 0xaa
0xf730 171 % 0xab
0xf731 172 % 0xac
0xf732 173 % 0xad
0xf733 174 % 0xae
0xf734 175 % 0xaf
0xf735 176 % 0xb0
0xf736 177 % 0xb1
0xf737 178 % 0xb2
0xf738 179 % 0xb3
0xf739 180 % 0xb4
0xf73f 181 % 0xb5
0xf760 182 % 0xb6
0xf761 183 % 0xb7
0xf762 184 % 0xb8
0xf763 185 % 0xb9
0xf764 186 % 0xba
0xf765 187 % 0xbb
0xf766 188 % 0xbc
0xf767 189 % 0xbd
0xf768 190 % 0xbe
0xf769 191 % 0xbf
0xf76a 192 % 0xc0
0xf76b 193 % 0xc1
0xf76c 194 % 0xc2
0xf76d 195 % 0xc3
0xf76e 196 % 0xc4
0xf76f 197 % 0xc5
0xf770 198 % 0xc6
0xf771 199 % 0xc7
0xf772 200 % 0xc8
0xf773 201 % 0xc9
0xf774 202 % 0xca
0xf775 203 % 0xcb
0xf776 204 % 0xcc
0xf777 205 % 0xcd
0xf778 206 % 0xce
0xf779 207 % 0xcf
0xf77a 208 % 0xd0
0xf7a1 209 % 0xd1
0xf7a2 210 % 0xd2
0xf7a8 211 % 0xd3
0xf7af 212 % 0xd4
0xf7b4 213 % 0xd5
0xf7b8 214 % 0xd6
0xf7bf 215 % 0xd7
0xf7e0 216 % 0xd8
0xf7e1 217 % 0xd9
0xf7e2 218 % 0xda
0xf7e3 219 % 0xdb
0xf7e4 220 % 0xdc
0xf7e5 221 % 0xdd
0xf7e6 222 % 0xde
0xf7e7 223 % 0xdf
0xf7e8 224 % 0xe0
0xf7e9 225 % 0xe1
0xf7ea 226 % 0xe2
0xf7eb 227 % 0xe3
0xf7ec 228 % 0xe4
0xf7ed 229 % 0xe5
0xf7ee 230 % 0xe6
0xf7ef 231 % 0xe7
0xf7f0 232 % 0xe8
0xf7f1 233 % 0xe9
0xf7f2 234 % 0xea
0xf7f3 235 % 0xeb
0xf7f4 236 % 0xec
0xf7f5 237 % 0xed
0xf7f6 238 % 0xee
0xf7f8 239 % 0xef
0xf7f9 240 % 0xf0
0xf7fa 241 % 0xf1
0xf7fb 242 % 0xf2
0xf7fc 243 % 0xf3
0xf7fd 244 % 0xf4
0xf7fe 245 % 0xf5
0xf7ff 246 % 0xf6
0xf8e5 247 % 0xf7
0xf8e6 248 % 0xf8
0xf8e7 249 % 0xf9
0xf8e8 250 % 0xfa
0xf8e9 251 % 0xfb
0xf8ea 252 % 0xfc
0xf8eb 253 % 0xfd
0xf8ec 254 % 0xfe
0xf8ed 255 % 0xff
@@ -1,31 +0,0 @@
% Encoding definition for PDFlib
% ttenc4
% WARNING: MACHINE GENERATED DON'T CHANGE!
% Format: unicode (hex) index (decimal) % index (hex)
0xf8ee 0 % 0x00
0xf8ef 1 % 0x01
0xf8f0 2 % 0x02
0xf8f1 3 % 0x03
0xf8f2 4 % 0x04
0xf8f3 5 % 0x05
0xf8f4 6 % 0x06
0xf8f5 7 % 0x07
0xf8f6 8 % 0x08
0xf8f7 9 % 0x09
0xf8f8 10 % 0x0a
0xf8f9 11 % 0x0b
0xf8fa 12 % 0x0c
0xf8fb 13 % 0x0d
0xf8fc 14 % 0x0e
0xf8fd 15 % 0x0f
0xf8fe 16 % 0x10
0xfb00 17 % 0x11
0xfb01 18 % 0x12
0xfb02 19 % 0x13
0xfb03 20 % 0x14
0xfb04 21 % 0x15
0xfb1f 22 % 0x16
0xfb2a 23 % 0x17
0xfb2b 24 % 0x18
0xfb35 25 % 0x19
0xfb4b 26 % 0x1a
@@ -1,48 +0,0 @@
/*
AboutText.cpp
Copyright (c) 2001-2006 Haiku.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <InterfaceDefs.h>
/*
static const char*
kAbout =
"PDF Writer for BeOS\n"
B_UTF8_COPYRIGHT " 2001-2004 Haiku\n"
"\n"
"Philippe Houdoin\n"
"\tProject Leader\n\n"
"Simon Gauvin\n"
"\tGUI Design\n\n"
"Michael Pfeiffer\n"
"\tPDF Generation\n"
"\tConfiguration\n"
"\tInteractive Features\n"
"\t" B_UTF8_ELLIPSIS
;
*/
@@ -1,379 +0,0 @@
/*
AdvancedSettingsWindow.cpp
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "AdvancedSettingsWindow.h"
#include "PrintUtils.h"
#include <Box.h>
#include <Button.h>
#include <FindDirectory.h>
#include <LayoutBuilder.h>
#include <MenuField.h>
#include <Message.h>
#include <Messenger.h>
#include <Path.h>
#include <PopUpMenu.h>
#include <Screen.h>
#include <SeparatorView.h>
#include <TextControl.h>
static BMessage* BorderWidthMessage(uint32 what, float width)
{
BMessage* m = new BMessage(what);
m->AddFloat("width", width);
return m;
}
AdvancedSettingsWindow::AdvancedSettingsWindow(BMessage *settings)
: HWindow(BRect(0, 0, 450, 180), "Advanced settings", B_TITLED_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
fSettings(settings)
{
AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
BString licenseKey;
if (settings->FindString("pdflib_license_key", &licenseKey) != B_OK)
licenseKey = "Not supported.";
if (settings->FindBool("create_web_links", &fCreateLinks) != B_OK)
fCreateLinks = false;
if (settings->FindFloat("link_border_width", &fLinkBorderWidth))
fLinkBorderWidth = 1;
if (settings->FindBool("create_bookmarks", &fCreateBookmarks) != B_OK)
fCreateBookmarks = false;
if (settings->FindString("xrefs_file", &fXRefs) != B_OK)
fXRefs = "";
if (settings->FindString("bookmark_definition_file", &fBookmarkDefinition) != B_OK)
fBookmarkDefinition = "";
if (settings->FindBool("create_xrefs", &fCreateXRefs) != B_OK)
fCreateXRefs = false;
if (settings->FindInt32("close_option", (int32*)&fCloseOption) != B_OK)
fCloseOption = kNever;
fLicenseKey = new BTextControl("pdflib_license_key",
"PDFlib license key: ", "", NULL);
fLicenseKey->SetEnabled(false);
fLicenseKey->TextView()->HideTyping(true);
fLicenseKey->TextView()->SetText(licenseKey.String());
// Hide the license key field as it is only supported in the commercial
// version of of pdflib. Leave it here for layout atm.
fLicenseKey->Hide();
// border link
// bounds.OffsetBy(0.0, fLicenseKey->Bounds().Height() + 10.0);
BPopUpMenu* menuLinkBorder = new BPopUpMenu("Link Border");
menuLinkBorder->SetRadioMode(true);
BMenuField* menuFieldLinkBorder = new BMenuField("link_border_width_menu",
"Link border:", menuLinkBorder);
menuFieldLinkBorder->Menu()->SetLabelFromMarked(true);
BMenuItem* item;
menuLinkBorder->AddItem(item = new BMenuItem("None",
new BMessage(CREATE_LINKS_MSG)));
item->SetMarked(!fCreateLinks);
menuLinkBorder->AddSeparatorItem();
menuLinkBorder->AddItem(item = new BMenuItem("No border",
BorderWidthMessage(LINK_BORDER_MSG, 0.0)));
if (fCreateLinks && fLinkBorderWidth == 0)
item->SetMarked(true);
menuLinkBorder->AddItem(item = new BMenuItem("Normal border",
BorderWidthMessage(LINK_BORDER_MSG, 1.0)));
if (fCreateLinks && fLinkBorderWidth == 1)
item->SetMarked(true);
menuLinkBorder->AddItem(item = new BMenuItem("Bold border",
BorderWidthMessage(LINK_BORDER_MSG, 2.0)));
if (fCreateLinks && fLinkBorderWidth == 2)
item->SetMarked(true);
// bookmarks
BPopUpMenu* menuBookmark = new BPopUpMenu("Bookmark Definition File");
menuBookmark->SetRadioMode(true);
BMenuField* menuFieldBookmark = new BMenuField("definition_menu",
"Bookmark definition file:", menuBookmark);
menuFieldBookmark->Menu()->SetLabelFromMarked(true);
menuBookmark->AddItem(item = new BMenuItem("None",
new BMessage(CREATE_BOOKMARKS_MSG)));
item->SetMarked(!fCreateBookmarks);
menuBookmark->AddSeparatorItem();
BDirectory bookmarks(_SetupDirectory("bookmarks"));
if (bookmarks.InitCheck() == B_OK) {
BEntry entry;
while (bookmarks.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) {
char name[B_FILE_NAME_LENGTH];
if (entry.GetName(name) == B_OK) {
menuBookmark->AddItem(item = new BMenuItem(name, new BMessage(DEFINITION_MSG)));
if (fCreateBookmarks && strcmp(name, fBookmarkDefinition.String()) == 0)
item->SetMarked(true);
}
}
}
// cross references
BPopUpMenu* menuCrossReferences = new BPopUpMenu("Cross References File");
menuCrossReferences->SetRadioMode(true);
BMenuField* menuFieldCrossReferences = new BMenuField("xrefs_menu",
"Cross references file:", menuCrossReferences);
menuFieldCrossReferences->Menu()->SetLabelFromMarked(true);
menuCrossReferences->AddItem(item = new BMenuItem("None",
new BMessage(CREATE_XREFS_MSG)));
item->SetMarked(!fCreateXRefs);
menuCrossReferences->AddSeparatorItem();
BDirectory xrefs(_SetupDirectory("xrefs"));
if (xrefs.InitCheck() == B_OK) {
BEntry entry;
while (xrefs.GetNextEntry(&entry) != B_ENTRY_NOT_FOUND) {
char name[B_FILE_NAME_LENGTH];
if (entry.GetName(name) == B_OK) {
menuCrossReferences->AddItem(item = new BMenuItem(name,
new BMessage(XREFS_MSG)));
if (fCreateXRefs && strcmp(name, fXRefs.String()) == 0)
item->SetMarked(true);
}
}
}
BPopUpMenu* menuStatusWindow =
new BPopUpMenu("Close status window when done");
menuStatusWindow->SetRadioMode(true);
BMenuField* menuFieldStatusWindow = new BMenuField("close_option_menu",
"Close status window when done:", menuStatusWindow);
menuFieldStatusWindow->Menu()->SetLabelFromMarked(true);
_AddMenuItem(menuStatusWindow, "Never", kNever);
_AddMenuItem(menuStatusWindow, "No errors", kNoErrors);
_AddMenuItem(menuStatusWindow, "No errors or warnings",
kNoErrorsOrWarnings);
_AddMenuItem(menuStatusWindow, "No errors, warnings or info",
kNoErrorsWarningsOrInfo);
_AddMenuItem(menuStatusWindow, "Always", kAlways);
BButton *cancelButton = new BButton("cancel", "Cancel",
new BMessage(CANCEL_MSG));
BButton *okButton = new BButton("ok", "OK", new BMessage(OK_MSG));
okButton->MakeDefault(true);
BButton *openButton = new BButton("openSettingsFolder",
"Open settings folder" B_UTF8_ELLIPSIS,
new BMessage(OPEN_SETTINGS_FOLDER_MSG));
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
.Add(fLicenseKey->CreateLabelLayoutItem(), 0, 0)
.Add(fLicenseKey->CreateTextViewLayoutItem(), 1, 0)
.Add(menuFieldLinkBorder->CreateLabelLayoutItem(), 0, 1)
.Add(menuFieldLinkBorder->CreateMenuBarLayoutItem(), 1, 1)
.Add(menuFieldBookmark->CreateLabelLayoutItem(), 0, 2)
.Add(menuFieldBookmark->CreateMenuBarLayoutItem(), 1, 2)
.Add(menuFieldCrossReferences->CreateLabelLayoutItem(), 0, 3)
.Add(menuFieldCrossReferences->CreateMenuBarLayoutItem(), 1, 3)
.Add(menuFieldStatusWindow->CreateLabelLayoutItem(), 0, 4)
.Add(menuFieldStatusWindow->CreateMenuBarLayoutItem(), 1, 4)
.End()
.Add(new BSeparatorView(B_HORIZONTAL, B_FANCY_BORDER))
.AddGroup(B_HORIZONTAL)
.Add(openButton)
.AddGlue()
.Add(cancelButton)
.Add(okButton)
.End();
BRect winFrame(Frame());
BRect screenFrame(BScreen().Frame());
MoveTo((screenFrame.right - winFrame.right) / 2,
(screenFrame.bottom - winFrame.bottom) / 2);
}
void
AdvancedSettingsWindow::MessageReceived(BMessage *msg)
{
void *source;
BMenuItem *item = NULL;
if (msg->FindPointer("source", &source) == B_OK)
item = static_cast<BMenuItem*> (source);
switch (msg->what){
case OK_MSG: {
_UpdateSettings();
Quit();
} break;
case CANCEL_MSG: {
Quit();
} break;
case CREATE_LINKS_MSG: {
fCreateLinks = false;
} break;
case LINK_BORDER_MSG: {
float w;
if (msg->FindFloat("width", &w) == B_OK) {
fLinkBorderWidth = w;
fCreateLinks = true;
}
} break;
case CREATE_BOOKMARKS_MSG: {
fCreateBookmarks = false;
} break;
case DEFINITION_MSG: {
if (item) {
fBookmarkDefinition = item->Label();
fCreateBookmarks = true;
}
} break;
case CREATE_XREFS_MSG: {
fCreateXRefs = false;
} break;
case XREFS_MSG: {
if (item) {
fXRefs = item->Label();
fCreateXRefs = true;
}
} break;
case AUTO_CLOSE_MSG: {
int32 closeOption;
if (msg->FindInt32("close_option", &closeOption) == B_OK)
fCloseOption = (CloseOption)closeOption;
} break;
case OPEN_SETTINGS_FOLDER_MSG: {
BPath path;
find_directory(B_USER_SETTINGS_DIRECTORY, &path, false);
path.Append("PDF Writer");
entry_ref ref;
get_ref_for_path(path.Path(), &ref);
BMessenger tracker("application/x-vnd.Be-TRAK");
if (tracker.IsValid()) {
BMessage message(B_REFS_RECEIVED);
message.AddRef("refs", &ref);
tracker.SendMessage(&message);
}
} break;
default:
inherited::MessageReceived(msg);
break;
}
}
void
AdvancedSettingsWindow::_UpdateSettings()
{
#if 0
SetString(fSettings, "pdflib_license_key", fLicenseKey);
#endif
SetInt32(fSettings, "close_option", fCloseOption);
SetBool(fSettings, "create_web_links", fCreateLinks);
SetFloat(fSettings, "link_border_width", fLinkBorderWidth);
SetString(fSettings, "xrefs_file", fXRefs);
SetBool(fSettings, "create_xrefs", fCreateXRefs);
SetBool(fSettings, "create_bookmarks", fCreateBookmarks);
SetString(fSettings, "bookmark_definition_file", fBookmarkDefinition);
}
BDirectory
AdvancedSettingsWindow::_SetupDirectory(const char* dirName)
{
BPath path;
find_directory(B_USER_SETTINGS_DIRECTORY, &path, true);
BDirectory dir(path.Path());
if (dir.Contains("PDF Writer")) {
path.Append("PDF Writer");
dir.SetTo(path.Path());
} else {
dir.CreateDirectory("PDF Writer", &dir);
}
if (dir.Contains(dirName)) {
path.Append(dirName);
dir.SetTo(path.Path());
} else {
dir.CreateDirectory(dirName, &dir);
}
return dir;
}
void AdvancedSettingsWindow::_AddMenuItem(BPopUpMenu* menu, const char* label,
CloseOption option)
{
BMessage* msg = new BMessage(AUTO_CLOSE_MSG);
msg->AddInt32("close_option", option);
BMenuItem* item = new BMenuItem(label, msg);
menu->AddItem(item);
if (fCloseOption == option)
item->SetMarked(true);
}
@@ -1,89 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef ADVANCED_SETTINGS_WINDOW_H
#define ADVANCED_SETTINGS_WINDOW_H
#include "BlockingWindow.h"
#include "PrinterDriver.h"
#include <Directory.h>
#include <String.h>
class BMessage;
class BPopUpMenu;
class BTextControl;
class AdvancedSettingsWindow : public HWindow
{
typedef HWindow inherited;
public:
// Constructors, destructors, operators...
AdvancedSettingsWindow(BMessage *doc_info);
virtual void MessageReceived(BMessage *msg);
enum {
OK_MSG = 'ok__',
CANCEL_MSG = 'cncl',
CREATE_LINKS_MSG = 'clnk',
LINK_BORDER_MSG = 'lnkb',
CREATE_BOOKMARKS_MSG = 'cbmk',
DEFINITION_MSG = 'defi',
CREATE_XREFS_MSG = 'cxrf',
XREFS_MSG = 'xref',
AUTO_CLOSE_MSG = 'acls',
OPEN_SETTINGS_FOLDER_MSG = 'opsf',
};
private:
void _UpdateSettings();
BDirectory _SetupDirectory(const char* dirName);
void _AddMenuItem(BPopUpMenu* menu, const char* label, CloseOption option);
private:
BMessage* fSettings;
BTextControl* fLicenseKey;
bool fCreateLinks;
float fLinkBorderWidth;
bool fCreateBookmarks;
BString fBookmarkDefinition;
bool fCreateXRefs;
BString fXRefs;
CloseOption fCloseOption;
};
#endif
@@ -1,85 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <math.h>
#include "Bezier.h"
/*
Bezier curve of degree n with control points P[0] ... P[n]:
P(t) = sum i from 0 to n of B(i, n, t) * P[i]
Bernsteinpolynomial:
B(i, n, t) = n! / (i! * (n-i)!) * t^i * (1-t)^(n-i)
*/
Bezier::Bezier(BPoint *points, int noOfPoints)
{
int i;
fPoints = new BPoint[noOfPoints];
fBernsteinWeights = new double[noOfPoints];
fNoOfPoints = noOfPoints;
const int n = noOfPoints - 1;
for (i = 0; i < noOfPoints; i++) {
fPoints[i] = points[i];
fBernsteinWeights[i] = Fact(n) / (Fact(i) * Fact(n-i));
}
}
Bezier::~Bezier()
{
delete []fPoints;
delete []fBernsteinWeights;
}
double
Bezier::Fact(int n)
{
double f = 1;
for (; n > 0; n --) f *= n;
return f;
}
BPoint
Bezier::PointAt(float t)
{
const int n = fNoOfPoints - 1;
double x, y;
x = y = 0.0;
for (int i = 0; i < fNoOfPoints; i ++) {
double w = fBernsteinWeights[i] * pow(t, i) * pow(1 - t, n - i);
x += w * fPoints[i].x;
y += w * fPoints[i].y;
}
return BPoint(x, y);
}
@@ -1,49 +0,0 @@
/*
Bezier curve
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef BEZIER_H
#define BEZIER_H
#include <Point.h>
class Bezier
{
BPoint *fPoints;
int fNoOfPoints;
double *fBernsteinWeights;
double Fact(int n);
public:
Bezier(BPoint *points, int n);
~Bezier();
BPoint PointAt(float t);
};
#endif
@@ -1,206 +0,0 @@
#include <Debug.h>
#include "PDFWriter.h"
#include "Bookmark.h"
#include "Scanner.h"
#include "Report.h"
Bookmark::Definition::Definition(int level, BFont* font, bool expanded)
: fLevel(level)
, fFont(*font)
, fExpanded(expanded)
{
}
bool Bookmark::Definition::Matches(font_family* family, font_style* style, float size) const
{
font_family family0;
font_style style0;
if (fFont.Size() != size) return false;
fFont.GetFamilyAndStyle(&family0, &style0);
return strcmp(family0, *family) == 0 &&
strcmp(style0, *style) == 0;
}
Bookmark::Bookmark(PDFWriter* writer)
: fWriter(writer)
{
for (int i = 0; i < kMaxBookmarkLevels; i ++) {
fLevels[i] = 0;
}
}
Bookmark::Definition* Bookmark::Find(BFont* font) const
{
font_family family;
font_style style;
float size;
font->GetFamilyAndStyle(&family, &style);
size = font->Size();
for (int i = 0; i < fDefinitions.CountItems(); i++) {
Definition* definition = fDefinitions.ItemAt(i);
if (definition->Matches(&family, &style, size)) {
return definition;
}
}
return NULL;
}
void Bookmark::AddDefinition(int level, BFont* font, bool expanded)
{
ASSERT(1 <= level && level <= kMaxBookmarkLevels);
if (Find(font) == NULL) {
fDefinitions.AddItem(new Definition(level, font, expanded));
}
}
void Bookmark::AddBookmark(BPoint start, float height, const char* text, BFont* font)
{
Definition* definition = Find(font);
if (definition != NULL) {
fOutlines.AddItem(new Outline(start, height, text, definition));
}
}
int Bookmark::AscendingByStart(const Outline** a, const Outline** b) {
return (int)((*b)->Start().y - (*a)->Start().y);
}
void Bookmark::CreateBookmarks() {
char optList[256];
fOutlines.SortItems(AscendingByStart);
for (int i = 0; i < fOutlines.CountItems(); i++) {
BString ucs2;
Outline* o = fOutlines.ItemAt(i);
REPORT(kInfo, fWriter->fPage, "Bookmark '%s' at level %d", o->Text(), o->Level());
sprintf(optList, "type=fixed left=%f top=%f", o->Start().x, o->Start().y + o->Height());
PDF_set_parameter(fWriter->fPdf, "bookmarkdest", optList);
fWriter->ToPDFUnicode(o->Text(), ucs2);
int open = o->Expanded() ? 1 : 0;
int bookmark = PDF_add_bookmark(fWriter->fPdf, ucs2.String(), fLevels[o->Level()-1], open);
if (bookmark < 0) bookmark = 0;
for (int i = o->Level(); i < kMaxBookmarkLevels; i ++) {
fLevels[i] = bookmark;
}
}
// reset to default
PDF_set_parameter(fWriter->fPdf, "bookmarkdest", "type=fitwindow");
fOutlines.MakeEmpty();
}
// Reads bookmark definitions from file
/*
File Format: Definition.
Line comment starts with '#'.
Definition = Version { Font }.
Version = "Bookmarks" "2.0".
Font = Level Family Style Size Expanded.
Level = int.
Family = String.
Style = String.
Size = float.
Expanded = "expanded" | "collapsed". // new in version 2.0, version 1.0 defaults to collapsed
String = '"' string '"'.
*/
bool Bookmark::Exists(const char* f, const char* s) const {
font_family family;
font_style style;
uint32 flags;
int32 nFamilies;
int32 nStyles;
nFamilies = count_font_families();
for (int32 i = 0; i < nFamilies; i ++) {
if (get_font_family(i, &family, &flags) == B_OK && strcmp(f, family) == 0) {
nStyles = count_font_styles(family);
for (int32 j = 0; j < nStyles; j++) {
if (get_font_style(family, j, &style, &flags) == B_OK && strcmp(s, style) == 0) {
return true;
}
}
}
}
return false;
}
bool Bookmark::Read(const char* name) {
Scanner scnr(name);
if (scnr.InitCheck() == B_OK) {
BString s; float version; bool ok;
ok = scnr.ReadName(&s) && scnr.ReadFloat(&version);
if (!ok || strcmp(s.String(), "Bookmarks") != 0 || (version != 1.0 && version != 2.0) ) {
REPORT(kError, 0, "Bookmarks (line %d, column %d): '%s' not a bookmarks file or wrong version!", scnr.Line(), scnr.Column(), name);
return false;
}
while (!scnr.IsEOF()) {
float level, size;
bool expanded = false;
BString family, style, expand;
if (!(scnr.ReadFloat(&level) && level >= 1.0 && level <= 10.0)) {
REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid level", scnr.Line(), scnr.Column());
return false;
}
if (!scnr.ReadString(&family)) {
REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid font family", scnr.Line(), scnr.Column());
return false;
}
if (!scnr.ReadString(&style)) {
REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid font style", scnr.Line(), scnr.Column());
return false;
}
if (!scnr.ReadFloat(&size)) {
REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid font size", scnr.Line(), scnr.Column());
return false;
}
if (version == 2.0) {
if (!scnr.ReadName(&expand) || (strcmp(expand.String(), "expanded") != 0 && strcmp(expand.String(), "collapsed") != 0)) {
REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid expanded value", scnr.Line(), scnr.Column());
return false;
}
expanded = strcmp(expand.String(), "expanded") == 0;
}
if (Exists(family.String(), style.String())) {
BFont font;
font.SetFamilyAndStyle(family.String(), style.String());
font.SetSize(size);
AddDefinition((int)level, &font, expanded);
} else {
REPORT(kWarning, 0, "Bookmarks (line %d, column %d): Font %s-%s not available!", scnr.Line(), scnr.Column(), family.String(), style.String());
}
scnr.SkipSpaces();
}
return true;
} else {
REPORT(kError, 0, "Bookmarks: Could not open bookmarks file '%d'", name);
}
return false;
}
@@ -1,61 +0,0 @@
#ifndef _BOOKMARK_H
#define _BOOKMARK_H
#include <String.h>
#include <Font.h>
#include <List.h>
class PDFWriter;
const int kMaxBookmarkLevels = 10;
class Bookmark {
class Definition {
public:
int fLevel;
BFont fFont;
bool fExpanded;
Definition(int level, BFont* font, bool expanded);
bool Matches(font_family* family, font_style* style, float size) const;
};
class Outline {
public:
BPoint fStart;
float fHeight;
BString fText;
Definition *fDefinition;
Outline(BPoint start, float height, const char* text, Definition* definition) : fStart(start), fHeight(height), fText(text), fDefinition(definition) { }
int Level() const { return fDefinition->fLevel; }
bool Expanded() const { return fDefinition->fExpanded; }
const char* Text() const { return fText.String(); }
BPoint Start() const { return fStart; }
float Height() const { return fHeight; }
};
PDFWriter* fWriter;
TList<Definition> fDefinitions;
TList<Outline> fOutlines; // of the current page
int fLevels[kMaxBookmarkLevels+1];
bool Exists(const char* family, const char* style) const;
Definition* Find(BFont* font) const;
static int AscendingByStart(const Outline** a, const Outline** b);
public:
Bookmark(PDFWriter* writer);
// level starts with 1
void AddDefinition(int level, BFont* font, bool expanded);
void AddBookmark(BPoint start, float height, const char* text, BFont* font);
bool Read(const char* name); // adds definitions from file
void CreateBookmarks();
};
#endif
@@ -1,94 +0,0 @@
/*
"Special" Cache.
Copyright (c) 2003 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "Report.h"
#include "Cache.h"
#include <Debug.h>
class CIReference : public CacheItem {
public:
CIReference(CacheItem* item) : fItem(item) {
ASSERT(dynamic_cast<CIReference*>(item) == NULL);
}
bool Equals(CIDescription* desc) const {
return fItem->Equals(desc);
}
CacheItem* Reference() {
return fItem;
}
private:
CacheItem* fItem;
};
Cache::Cache()
: fPass(0)
, fNextID(0)
{};
void Cache::NextPass() {
fPass++;
fNextID = 0;
// max two passes!
ASSERT(fPass == 1);
}
CacheItem* Cache::Find(CIDescription* desc) {
REPORT(kDebug, -1, "Cache::Find() pass = %d next id = %d", fPass, fNextID);
int id = fNextID ++;
const int32 n = CountItems();
CacheItem* item = ItemAt(id);
// In 2. pass for each item an entry must exists
ASSERT(fPass != 1 || item != NULL);
if (fPass == 1) return item->Reference();
// In 1. pass we create an entry for each bitmap
for (int32 i = 0; i < n; i ++) {
item = ItemAt(i);
// skip references
if (item != item->Reference()) continue;
if (item->Equals(desc)) {
// found item in cache, create a reference to it
CacheItem* ref = new CIReference(item->Reference());
if (ref == NULL) return NULL;
fCache.AddItem(ref);
return item;
}
}
// item not in cache, create one
item = desc->NewItem(id);
if (item != NULL) {
ASSERT(dynamic_cast<CIReference*>(item) == NULL);
fCache.AddItem(item);
}
return item;
}
@@ -1,74 +0,0 @@
/*
"Special" Cache.
Copyright (c) 2003 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _CACHE_H
#define _CACHE_H
#include "PrintUtils.h"
class CacheItem;
// CacheItemDescription
class CIDescription {
public:
CIDescription() {};
virtual ~CIDescription() {};
virtual CacheItem* NewItem(int id) { return NULL; }
};
class CacheItem {
public:
CacheItem() {}
virtual ~CacheItem() {}
virtual bool Equals(CIDescription* desc) const = 0;
virtual CacheItem* Reference() { return this; }
};
class Cache {
public:
Cache();
virtual ~Cache() {};
void NextPass();
// returns the CacheItem at "NextID", returns NULL on error
CacheItem* Find(CIDescription* desc);
void MakeEmpty() { fCache.MakeEmpty(); }
int32 CountItems() const { return fCache.CountItems(); }
CacheItem* ItemAt(int32 i) const { return fCache.ItemAt(i); }
private:
int8 fPass;
int32 fNextID;
TList<CacheItem> fCache;
};
#endif
@@ -1,551 +0,0 @@
/*
DocInfoWindow.cpp
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "DocInfoWindow.h"
#include "PrintUtils.h"
#include <Box.h>
#include <Button.h>
#include <Menu.h>
#include <MenuItem.h>
#include <MenuField.h>
#include <Message.h>
#include <Screen.h>
#include <ScrollView.h>
#include <TabView.h>
#include <TextControl.h>
#include <ctype.h>
// #pragma mark -- DocInfoWindow
DocInfoWindow::DocInfoWindow(BMessage *docInfo)
: HWindow(BRect(0, 0, 400, 250), "Document information", B_TITLED_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL, B_NOT_MINIMIZABLE | B_CLOSE_ON_ESCAPE),
fDocInfo(docInfo)
{
BRect bounds(Bounds());
BView *background = new BView(bounds, "bachground", B_FOLLOW_ALL, B_WILL_DRAW);
background->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
AddChild(background);
bounds.InsetBy(10.0, 10.0);
BButton *button = new BButton(bounds, "ok", "OK", new BMessage(OK_MSG),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
background->AddChild(button);
button->ResizeToPreferred();
button->MoveTo(bounds.right - button->Bounds().Width(),
bounds.bottom - button->Bounds().Height());
BRect buttonFrame(button->Frame());
button = new BButton(buttonFrame, "cancel", "Cancel", new BMessage(CANCEL_MSG),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
background->AddChild(button);
button->ResizeToPreferred();
button->MoveTo(buttonFrame.left - (button->Bounds().Width() + 10.0),
buttonFrame.top);
bounds.bottom = buttonFrame.top - 10.0;
#if HAVE_FULLVERSION_PDF_LIB
BString permissions;
if (_DocInfo()->FindString("permissions", &permissions) == B_OK)
fPermissions.Decode(permissions.String());
BTabView *tabView = new BTabView(bounds, "tabView");
_SetupDocInfoView(_CreateTabPanel(tabView, "Information"));
_SetupPasswordView(_CreateTabPanel(tabView, "Password"));
_SetupPermissionsView(_CreateTabPanel(tabView, "Permissions"));
background->AddChild(tabView);
#else
BBox* panel = new BBox(bounds, "top_panel", B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_NO_BORDER);
_SetupDocInfoView(panel);
background->AddChild(panel);
#endif
if (fTable->ChildAt(0))
fTable->ChildAt(0)->MakeFocus();
BRect winFrame(Frame());
BRect screenFrame(BScreen().Frame());
MoveTo((screenFrame.right - winFrame.right) / 2,
(screenFrame.bottom - winFrame.bottom) / 2);
SetSizeLimits(400.0, 10000.0, 250.0, 10000.0);
}
void
DocInfoWindow::Quit()
{
_EmptyKeyList();
inherited::Quit();
}
bool
DocInfoWindow::QuitRequested()
{
return true;
}
void
DocInfoWindow::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case OK_MSG: {
BMessage doc_info;
_ReadFieldsFromTable(doc_info);
_DocInfo()->RemoveName("doc_info");
_DocInfo()->AddMessage("doc_info", &doc_info);
#if HAVE_FULLVERSION_PDF_LIB
_ReadPasswords();
_ReadPermissions();
#endif
Quit();
} break;
case CANCEL_MSG: {
Quit();
} break;
case ADD_KEY_MSG: {
case DEFAULT_KEY_MSG:
_AddKey(msg, msg->what == ADD_KEY_MSG);
} break;
case REMOVE_KEY_MSG: {
_RemoveKey(msg);
} break;
default: {
inherited::MessageReceived(msg);
} break;
}
}
void
DocInfoWindow::FrameResized(float newWidth, float newHeight)
{
BTextControl *textControl = dynamic_cast<BTextControl*> (fTable->ChildAt(0));
if (textControl) {
float width, height;
textControl->GetPreferredSize(&width, &height);
int32 count = fKeyList->CountItems();
float fieldsHeight = (height * count) + (2 * count);
_AdjustScrollBar(height, fieldsHeight);
while (textControl) {
textControl->SetDivider(textControl->Bounds().Width() / 2.0);
textControl = dynamic_cast<BTextControl*> (textControl->NextSibling());
}
}
}
void
DocInfoWindow::_SetupDocInfoView(BBox* panel)
{
BRect bounds(panel->Bounds());
#if HAVE_FULLVERSION_PDF_LIB
bounds.InsetBy(10.0, 10.0);
#endif
// add list of keys
fKeyList = new BMenu("Delete key");
BMenuField *menu = new BMenuField(bounds, "delete", "", fKeyList,
B_FOLLOW_BOTTOM);
panel->AddChild(menu);
menu->SetDivider(0);
#ifdef __HAIKU__
menu->ResizeToPreferred();
menu->MoveTo(bounds.left, bounds.bottom - menu->Bounds().Height());
#else
menu->ResizeTo(menu->StringWidth("Delete key") + 15.0, 25.0);
menu->MoveTo(bounds.left, bounds.bottom - 25.0);
#endif
const char* title[6] = { "Title", "Author", "Subject", "Keywords", "Creator",
NULL }; // PDFlib sets these: "Producer", "CreationDate", not "ModDate"
BMenu* defaultKeys = new BMenu("Default keys");
for (int32 i = 0; title[i] != NULL; ++i)
defaultKeys->AddItem(new BMenuItem(title[i], new BMessage(DEFAULT_KEY_MSG)));
BRect frame(menu->Frame());
menu = new BMenuField(frame, "add", "", defaultKeys, B_FOLLOW_BOTTOM);
panel->AddChild(menu);
menu->SetDivider(0);
#ifdef __HAIKU__
menu->ResizeToPreferred();
menu->MoveBy(frame.Width() + 10.0, 0.0);
#else
menu->ResizeTo(menu->StringWidth("Default keys") + 15.0, 25.0);
menu->MoveBy(menu->Bounds().Width() + 10.0, 0.0);
#endif
frame = menu->Frame();
frame.left = frame.right + 10.0;
frame.right = bounds.right;
BTextControl *add = new BTextControl(frame, "add", "Add key:", "",
new BMessage(ADD_KEY_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
panel->AddChild(add);
float width, height;
add->GetPreferredSize(&width, &height);
add->ResizeTo(bounds.right - frame.left, height);
add->SetDivider(be_plain_font->StringWidth("Add key: "));
bounds.bottom = frame.top - 10.0;
bounds.right -= B_V_SCROLL_BAR_WIDTH;
bounds.InsetBy(2.0, 2.0);
fTable = new BView(bounds, "table", B_FOLLOW_ALL, B_WILL_DRAW);
fTable->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
fTableScrollView = new BScrollView("scroll_table", fTable, B_FOLLOW_ALL, 0,
false, true);
panel->AddChild(fTableScrollView);
BMessage docInfo;
fDocInfo->FindMessage("doc_info", &docInfo);
// fill table
_BuildTable(docInfo);
}
void
DocInfoWindow::_BuildTable(const BMessage& docInfo)
{
_EmptyKeyList();
while (fTable->ChildAt(0)) {
BView *child = fTable->ChildAt(0);
fTable->RemoveChild(child);
delete child;
}
fTable->ScrollTo(0, 0);
#ifdef B_BEOS_VERSION_DANO
const
#endif
char *name;
uint32 type;
int32 count;
float rowHeight = 20.0;
float fieldsHeight = 2.0;
float width = fTable->Bounds().Width() - 4.0;
for (int32 i = 0; docInfo.GetInfo(B_STRING_TYPE, i, &name, &type, &count)
== B_OK; i++) {
if (type != B_STRING_TYPE)
continue;
BString value;
BTextControl* textControl;
if (docInfo.FindString(name, &value) == B_OK) {
BRect rect(2.0, fieldsHeight, width, rowHeight);
textControl = _AddFieldToTable(rect, name, value.String());
rowHeight = textControl->Bounds().Height();
fieldsHeight += rowHeight + 2.0;
}
}
_AdjustScrollBar(rowHeight, fieldsHeight);
}
BTextControl*
DocInfoWindow::_AddFieldToTable(BRect rect, const char* name, const char* value)
{
BTextControl *textControl = new BTextControl(rect, name, name, value, NULL,
B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW | B_NAVIGABLE);
fTable->AddChild(textControl);
float width, height;
textControl->GetPreferredSize(&width, &height);
textControl->ResizeTo(rect.Width(), height);
textControl->SetDivider(rect.Width() / 2.0);
fKeyList->AddItem(new BMenuItem(name, new BMessage(REMOVE_KEY_MSG)));
return textControl;
}
void
DocInfoWindow::_AdjustScrollBar(float controlHeight, float fieldsHeight)
{
BScrollBar *sb = fTableScrollView->ScrollBar(B_VERTICAL);
if (!sb)
return;
sb->SetRange(0.0, 0.0);
float tableHeight = fTable->Bounds().Height();
if ((fieldsHeight - tableHeight) > 0.0) {
sb->SetProportion(tableHeight / fieldsHeight);
sb->SetRange(0.0, fieldsHeight - tableHeight);
sb->SetSteps(controlHeight + 2.0, tableHeight);
}
}
void
DocInfoWindow::_ReadFieldsFromTable(BMessage& docInfo)
{
docInfo.MakeEmpty();
BView* child;
for (int32 i = 0; (child = fTable->ChildAt(i)) != NULL; i++) {
BTextControl* textControl = dynamic_cast<BTextControl*>(child);
if (textControl)
docInfo.AddString(textControl->Label(), textControl->Text());
}
}
void
DocInfoWindow::_RemoveKey(BMessage *msg)
{
void *p;
if (msg->FindPointer("source", &p) != B_OK)
return;
BMenuItem *item = reinterpret_cast<BMenuItem*>(p);
if (!item)
return;
BMessage docInfo;
_ReadFieldsFromTable(docInfo);
const char *label = item->Label();
if (docInfo.HasString(label)) {
docInfo.RemoveName(label);
_BuildTable(docInfo);
}
}
bool
DocInfoWindow::_IsKeyValid(const char* key) const
{
if (*key == 0)
return false;
while (*key) {
if (isspace(*key) || iscntrl(*key))
break;
key++;
}
return *key == 0;
}
void
DocInfoWindow::_AddKey(BMessage *msg, bool textControl)
{
void *p;
if (msg->FindPointer("source", &p) != B_OK || p == NULL)
return;
const char* key = NULL;
if (textControl) {
BTextControl *text = reinterpret_cast<BTextControl*>(p);
key = text->Text();
} else {
BMenuItem *item = reinterpret_cast<BMenuItem*>(p);
key = item->Label();
}
if (!_IsKeyValid(key))
return;
BMessage docInfo;
_ReadFieldsFromTable(docInfo);
if (!docInfo.HasString(key)) {
// key is valid and is not in list already
docInfo.AddString(key, "");
float width = fTable->Bounds().Width() - 4.0;
BTextControl *textControl =
_AddFieldToTable(BRect(2.0, 0.0, width, 20.0), key, "");
float rowHeight = textControl->Bounds().Height();
int32 count = fKeyList->CountItems();
float fieldsHeight = (rowHeight * count) + (2 * count);
textControl->MoveTo(2.0, fieldsHeight - rowHeight);
_AdjustScrollBar(rowHeight, fieldsHeight);
}
}
void
DocInfoWindow::_EmptyKeyList()
{
while (fKeyList->CountItems() > 0L)
delete fKeyList->RemoveItem((int32)0);
}
#if HAVE_FULLVERSION_PDF_LIB
void
DocInfoWindow::_SetupPasswordView(BBox* panel)
{
BRect bounds(panel->Bounds().InsetByCopy(10.0, 10.0));
fMasterPassword = _AddPasswordControl(bounds, panel, "master_password",
"Master password:");
bounds.OffsetBy(0, fMasterPassword->Bounds().Height());
fUserPassword = _AddPasswordControl(bounds, panel, "user_password",
"User password:");
float divider = max_c(panel->StringWidth("Master password:"),
panel->StringWidth("User password:"));
fMasterPassword->SetDivider(divider);
fUserPassword->SetDivider(divider);
}
void
DocInfoWindow::_SetupPermissionsView(BBox* panel)
{
(void)panel;
}
BBox*
DocInfoWindow::_CreateTabPanel(BTabView* tabView, const char* label)
{
BRect rect(tabView->Bounds().InsetByCopy(3.0, 15.0));
rect.OffsetTo(B_ORIGIN);
BBox* panel = new BBox(rect, "top_panel", B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_NO_BORDER);
BTab* tab = new BTab();
tabView->AddTab(panel, tab);
tab->SetLabel(label);
return panel;
}
BTextControl*
DocInfoWindow::_AddPasswordControl(BRect r, BView* panel, const char* name,
const char* label)
{
BString text;
_DocInfo()->FindString(name, &text);
BTextControl* textControl = new BTextControl(r, name, label, "", NULL,
B_FOLLOW_LEFT_RIGHT);
panel->AddChild(textControl);
textControl->ResizeToPreferred();
textControl->TextView()->HideTyping(true);
textControl->TextView()->SetText(text.String());
return textControl;
}
void
DocInfoWindow::_ReadPasswords()
{
SetString(_DocInfo(), "master_password", fMasterPassword->TextView()->Text());
SetString(_DocInfo(), "user_password", fUserPassword->TextView()->Text());
}
void
DocInfoWindow::_ReadPermissions()
{
BString permissions;
fPermissions.Encode(permissions);
SetString(_DocInfo(), "permissions", permissions.String());
}
// #pragma mark -- Permissions
// pdflib 5.x supports password protection and permissions in the commercial version only!
static const PermissionLabels gPermissionLabels[] = {
PermissionLabels("Prevent printing the file.", "noprint"),
PermissionLabels("Prevent making any changes.", "nomodify"),
PermissionLabels("Prevent copying or extracting text or graphics.", "nocopy"),
PermissionLabels("Prevent adding or changing comments or form fields.", "noannots"),
PermissionLabels("Prevent form field filling.", "noforms"),
PermissionLabels("Prevent extracting text of graphics.", "noaccessible"),
PermissionLabels("Prevent inserting, deleting, or rotating pages and creating "
"bookmarks and thumbnails, even if nomodify hasn't been specified", "noassemble"),
PermissionLabels("Prevent high-resolution printing.", "nohiresprint")
};
Permissions::Permissions()
{
fNofPermissions = sizeof(gPermissionLabels) / sizeof(PermissionLabels);
fPermissions = new Permission[fNofPermissions];
for (int32 i = 0; i < fNofPermissions; i++)
fPermissions[i].SetLabels(&gPermissionLabels[i]);
}
void Permissions::Decode(const char* s)
{
for (int32 i = 0; i < fNofPermissions; i++)
At(i)->SetAllowed((strstr(s, At(i)->GetPDFName()) == NULL));
}
void Permissions::Encode(BString& permissions)
{
permissions.Truncate(0);
for (int32 i = 0; i < fNofPermissions; i++) {
if (!At(i)->IsAllowed())
permissions.Append(At(i)->GetPDFName()).Append(" ");
}
}
#endif // HAVE_FULLVERSION_PDF_LIB
@@ -1,164 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef DOCINFOWINDOW_H
#define DOCINFOWINDOW_H
#include "BlockingWindow.h"
#include <String.h>
class BBox;
class BMenu;
class BScrollView;
class BTabView;
class BTextControl;
class BView;
#define HAVE_FULLVERSION_PDF_LIB 0
#if HAVE_FULLVERSION_PDF_LIB
class PermissionLabels {
public:
PermissionLabels(const char* name, const char* pdfName)
: fName(name), fPDFName(pdfName) { }
const char* GetName() const { return fName; }
const char* GetPDFName() const { return fName; }
private:
const char* fName;
const char* fPDFName;
};
class Permission {
public:
Permission()
: fLabels(NULL), fAllowed(true) { }
const char* GetName() const { return fLabels->GetName(); }
const char* GetPDFName() const { return fLabels->GetPDFName(); }
bool IsAllowed() const { return fAllowed; }
void SetLabels(const PermissionLabels* labels) { fLabels = labels; }
void SetAllowed(bool allowed) { fAllowed = allowed; }
private:
const PermissionLabels* fLabels;
bool fAllowed;
};
class Permissions {
public:
Permissions();
// accessors
Permission* At(int32 i) { return &fPermissions[i]; }
int32 Length() const { return fNofPermissions; }
// decode/encode pdflib permission string
void Decode(const char* s);
void Encode(BString& permissions);
private:
Permission* fPermissions;
int32 fNofPermissions;
};
#endif // HAVE_FULLVERSION_PDF_LIB
class DocInfoWindow : public HWindow
{
typedef HWindow inherited;
public:
DocInfoWindow(BMessage *doc_info);
virtual void Quit();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
virtual void FrameResized(float newWidth, float newHeight);
enum {
OK_MSG = 'ok__',
CANCEL_MSG = 'cncl',
ADD_KEY_MSG = 'add_',
REMOVE_KEY_MSG = 'rmov',
DEFAULT_KEY_MSG = 'dflt',
};
private:
BMessage* _DocInfo() { return fDocInfo; }
void _SetupDocInfoView(BBox* panel);
void _BuildTable(const BMessage& fromDocInfo);
void _AdjustScrollBar(float controlHeight,
float fieldsHeight);
BTextControl* _AddFieldToTable(BRect rect, const char* name,
const char* value);
void _ReadFieldsFromTable(BMessage& docInfo);
void _RemoveKey(BMessage* msg);
bool _IsKeyValid(const char *key) const;
void _AddKey(BMessage* msg, bool textControl);
void _EmptyKeyList();
#if HAVE_FULLVERSION_PDF_LIB
void _SetupPasswordView(BBox* panel);
void _SetupPermissionsView(BBox* panel);
BBox* _CreateTabPanel(BTabView* tabView, const char* label);
BTextControl* _AddPasswordControl(BRect r, BView* panel,
const char* name, const char* label);
void _ReadPasswords();
void _ReadPermissions();
#endif // HAVE_FULLVERSION_PDF_LIB
private:
BMessage* fDocInfo; // owned by parent window
BView* fTable;
BScrollView* fTableScrollView;
BMenu* fKeyList;
#if HAVE_FULLVERSION_PDF_LIB
BTextControl* fMasterPassword;
BTextControl* fUserPassword;
Permissions fPermissions;
#endif // HAVE_FULLVERSION_PDF_LIB
};
#endif
@@ -1,201 +0,0 @@
/*
DrawShape
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "DrawShape.h"
#include "Bezier.h"
#include "PDFLinePathBuilder.h"
#include "Log.h"
#include "Report.h"
#include "PDFWriter.h"
#ifdef CODEWARRIOR
#pragma mark [BShape drawing support routines]
#endif
// --------------------------------------------------
DrawShape::DrawShape(PDFWriter *writer, bool stroke)
: fWriter(writer)
, fStroke(stroke)
, fDrawn(false)
, fCurrentPoint(0, 0)
{
}
// --------------------------------------------------
DrawShape::~DrawShape()
{
Draw();
}
// --------------------------------------------------
// approximate length of bezier curve
float
DrawShape::BezierLength(BPoint *curve, int n) {
float len = 0.0;
if (n <= 0) return len;
BPoint start = curve[0];
for (int i = 1; i < n; i++) {
BPoint end = curve[i];
BPoint diff = start - end;
len += sqrt(diff.x * diff.x + diff.y * diff.y);
start = end;
}
return scale(len);
}
// --------------------------------------------------
int
DrawShape::BezierPoints(BPoint *curve, int n) {
float len = BezierLength(curve, n);
if (len <= kMinBezierPoints) return kMinBezierPoints;
if (len > kMaxBezierPoints) return kMaxBezierPoints;
return (int)len;
}
// --------------------------------------------------
void
DrawShape::CreateBezierPath(BPoint *curve) {
Bezier bezier(curve, 4);
const int n = BezierPoints(curve, 4)-1;
REPORT(kDebug, 0, "BezierPoints %d", n);
for (int i = 0; i <= n; i ++) {
fSubPath.AddPoint(bezier.PointAt(i / (float) n));
}
}
// --------------------------------------------------
void
DrawShape::EndSubPath()
{
PDFLinePathBuilder builder(&fSubPath, fWriter);
builder.CreateLinePath();
}
// --------------------------------------------------
status_t
DrawShape::IterateBezierTo(int32 bezierCount, BPoint *control)
{
REPORT(kDebug, 0, "BezierTo");
for (int32 i = 0; i < bezierCount; i++, control += 3) {
REPORT(kDebug, 0," (%f %f) (%f %f) (%f %f)", tx(control[0].x), ty(control[0].y), tx(control[1].x), ty(control[1].y), tx(control[2].x), ty(control[2].y));
if (TransformPath()) {
BPoint p[4] = { fCurrentPoint, control[0], control[1], control[2] };
CreateBezierPath(p);
} else {
PDF_curveto(Pdf(),
tx(control[0].x), ty(control[0].y),
tx(control[1].x), ty(control[1].y),
tx(control[2].x), ty(control[2].y));
}
fCurrentPoint = control[2];
}
return B_OK;
}
// --------------------------------------------------
status_t
DrawShape::IterateClose(void)
{
REPORT(kDebug, 0, "IterateClose %s", IsDrawing() ? (fStroke ? "stroke" : "fill") : "clip");
if (fDrawn) REPORT(kDebug, 0, ">>> IterateClose called multiple times!");
if (TransformPath())
fSubPath.Close();
else
PDF_closepath(Pdf());
Draw();
return B_OK;
}
// --------------------------------------------------
void
DrawShape::Draw()
{
if (!fDrawn) {
fDrawn = true;
if (IsDrawing()) {
if (fStroke)
fWriter->StrokeOrClip(); // strokes always
else {
fWriter->FillOrClip(); // fills always
}
} else if (TransformPath()) {
EndSubPath();
} else {
PDF_closepath(Pdf());
}
}
}
// --------------------------------------------------
status_t
DrawShape::IterateLineTo(int32 lineCount, BPoint *linePoints)
{
REPORT(kDebug, 0, "IterateLineTo %d", (int)lineCount);
BPoint *p = linePoints;
for (int32 i = 0; i < lineCount; i++) {
REPORT(kDebug, 0, "(%f, %f) ", p->x, p->y);
if (TransformPath()) {
fSubPath.AddPoint(*p);
} else {
PDF_lineto(Pdf(), tx(p->x), ty(p->y));
}
fCurrentPoint = *p;
p++;
}
return B_OK;
}
// --------------------------------------------------
status_t
DrawShape::IterateMoveTo(BPoint *point)
{
REPORT(kDebug, 0, "IterateMoveTo ");
if (!TransformPath()) {
PDF_moveto(Pdf(), tx(point->x), ty(point->y));
} else {
EndSubPath();
fSubPath.MakeEmpty();
fSubPath.AddPoint(*point);
}
REPORT(kDebug, 0, "(%f, %f)", point->x, point->y);
fCurrentPoint = *point;
return B_OK;
}
@@ -1,79 +0,0 @@
/*
DrawShape
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef DRAW_SHAPE_H
#define DRAW_SHAPE_H
#include "PDFWriter.h"
class DrawShape : public BShapeIterator
{
PDFWriter *fWriter;
bool fStroke;
bool fDrawn;
BPoint fCurrentPoint;
SubPath fSubPath;
inline FILE *Log() { return fWriter->fLog; }
inline PDF *Pdf() { return fWriter->fPdf; }
inline float tx(float x) { return fWriter->tx(x); }
inline float ty(float y) { return fWriter->ty(y); }
inline float scale(float f) { return fWriter->scale(f); }
inline bool IsDrawing() const { return fWriter->IsDrawing(); }
inline bool IsClipping() const { return fWriter->IsClipping(); }
inline bool IsStroking() const { return fStroke; }
inline bool IsFilling() const { return !fStroke; }
inline float PenSize() const { return fWriter->PenSize(); }
inline bool TransformPath() const { return IsStroking() && IsClipping(); }
enum {
kMinBezierPoints = 2, // must be greater or equal to 2
kMaxBezierPoints = 30
};
float BezierLength(BPoint *p, int n);
int BezierPoints(BPoint *p, int n);
void CreateBezierPath(BPoint *p);
void EndSubPath();
public:
DrawShape(PDFWriter *writer, bool stroke);
~DrawShape();
status_t IterateBezierTo(int32 bezierCount, BPoint *bezierPoints);
status_t IterateClose(void);
status_t IterateLineTo(int32 lineCount, BPoint *linePoints);
status_t IterateMoveTo(BPoint *point);
void Draw();
};
#endif
@@ -1,136 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include <StorageKit.h>
#include "Driver.h"
#include "PDFWriter.h"
#include "PrinterDriver.h"
#include "PrinterSettings.h"
static PrinterDriver *instanciate_driver(BNode *spoolDir);
// ======== For testing only ==================
BMessage*
take_job(BFile *spoolFile, BNode *spoolDir, BMessage *msg)
{
PrinterDriver *driver = instanciate_driver(spoolDir);
status_t status = driver->PrintJob(spoolFile, spoolDir, msg);
delete driver;
msg = new BMessage('okok');
if (status != B_OK)
msg->what = 'baad';
return msg;
}
BMessage*
config_page(BNode *spoolDir, BMessage *msg)
{
BMessage *pagesetupMsg = new BMessage(*msg);
PrinterSettings::Read(spoolDir, pagesetupMsg, PrinterSettings::kPageSettings);
BString printerName;
spoolDir->ReadAttrString("Printer Name", &printerName);
PrinterDriver *driver = instanciate_driver(spoolDir);
if (driver->PageSetup(pagesetupMsg, printerName.String()) == B_OK) {
pagesetupMsg->what = 'okok';
PrinterSettings::Update(spoolDir, pagesetupMsg,
PrinterSettings::kPageSettings);
} else {
delete pagesetupMsg;
pagesetupMsg = NULL;
}
delete driver;
return pagesetupMsg;
}
BMessage*
config_job(BNode *spoolDir, BMessage *msg)
{
BMessage *jobsetupMsg = new BMessage(*msg);
PrinterSettings::Read(spoolDir, jobsetupMsg, PrinterSettings::kJobSettings);
BString printerName;
spoolDir->ReadAttrString("Printer Name", &printerName);
PrinterDriver *driver = instanciate_driver(spoolDir);
if (driver->JobSetup(jobsetupMsg, printerName.String()) == B_OK) {
jobsetupMsg->what = 'okok';
PrinterSettings::Update(spoolDir, jobsetupMsg,
PrinterSettings::kJobSettings);
} else {
delete jobsetupMsg;
jobsetupMsg = NULL;
}
delete driver;
return jobsetupMsg;
}
char*
add_printer(char *printerName)
{
return printerName;
}
static PrinterDriver*
instanciate_driver(BNode *spoolDir)
{
return new PDFWriter();
}
/**
* default_settings
*
* @param BNode* printer spool directory
* @return BMessage* the settings
*/
BMessage*
default_settings(BNode* printer)
{
BMessage *msg = new BMessage();
PrinterSettings::Read(printer, msg, PrinterSettings::kPageSettings);
return msg;
}
@@ -1,41 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <AppKit.h>
extern "C"
{
BMessage * take_job(BFile * spool_file, BNode * spool_dir, BMessage * msg);
BMessage * config_page(BNode * spool_dir, BMessage * msg);
BMessage * config_job(BNode * spool_dir, BMessage * msg);
char * add_printer(char * printer_name);
BMessage * default_settings(BNode * printer);
}
@@ -1,560 +0,0 @@
/*
Copyright (c) 2001, 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <stdio.h>
#include <malloc.h>
#include <StorageKit.h>
#include "Fonts.h"
#include "Report.h"
// FontFile
// ---------------------------------------
// Implementation of BArchivable interface
// ---------------------------------------
// --------------------------------------------------
FontFile::FontFile(BMessage *archive)
{
int8 type;
archive->FindString("name", &fName);
archive->FindString("path", &fPath);
archive->FindInt64 ("size", &fSize);
if (B_OK == archive->FindInt8 ("type", &type))
fType = (font_type)type;
else
fType = unknown_type;
archive->FindBool ("embed", &fEmbed);
archive->FindString("subst", &fSubst);
}
// --------------------------------------------------
BArchivable *FontFile::Instantiate(BMessage *archive)
{
if (!validate_instantiation(archive, "FontFile")) {
return NULL;
}
return new FontFile(archive);
}
// --------------------------------------------------
status_t FontFile::Archive(BMessage *archive, bool deep) const
{
archive->AddString("class", "FontFile");
archive->AddString("name", fName);
archive->AddString("path", fPath);
archive->AddInt64 ("size", fSize);
archive->AddInt8 ("type", (int8)fType);
archive->AddBool ("embed", fEmbed);
archive->AddString("subst", fSubst);
return B_OK;
}
// Fonts
#define fmin(x, y) ( (x < y) ? x : y);
#define TRUETYPE_VERSION 0x00010000
#define OPENTYPE_CFF_VERSION 'OTTO'
#define TRUETTYPE_TABLE_NAME_TAG 'name'
static uint16 ttf_get_uint16(FILE * ttf);
static uint32 ttf_get_uint32(FILE *ttf);
static status_t ttf_get_fontname(const char * path, char * fontname, size_t fn_size);
static status_t psf_get_fontname(const char * path, char * fontname, size_t fn_size);
// --------------------------------------------------
Fonts::Fonts()
{
SetDefaultCJKOrder();
}
void
Fonts::SetDefaultCJKOrder()
{
SetCJKOrder(0, japanese_encoding, true);
SetCJKOrder(1, chinese_gb1_encoding, true);
SetCJKOrder(2, chinese_cns1_encoding, true);
SetCJKOrder(3, korean_encoding, true);
}
// --------------------------------------------------
bool
Fonts::SetCJKOrder(int i, font_encoding enc, bool active)
{
if (0 <= i && i < no_of_cjk_encodings) {
fCJKOrder[i].encoding = enc;
fCJKOrder[i].active = active;
return true;
}
return false;
}
// --------------------------------------------------
bool
Fonts::GetCJKOrder(int i, font_encoding& enc, bool& active) const
{
if (0 <= i && i < no_of_cjk_encodings) {
enc = fCJKOrder[i].encoding;
active = fCJKOrder[i].active;
return true;
}
return false;
}
// ---------------------------------------
// Implementation of BArchivable interface
// ---------------------------------------
// --------------------------------------------------
Fonts::Fonts(BMessage *archive)
{
BMessage m;
for (int i = 0; archive->FindMessage("fontfile", i, &m) == B_OK; i++) {
BArchivable* base = instantiate_object(&m);
if (base) {
FontFile* f = dynamic_cast<FontFile*>(base);
if (f) fFontFiles.AddItem(f);
else delete f;
}
}
if (archive->FindMessage("cjk_order", &m) == B_OK) {
for (int i = 0; i < no_of_cjk_encodings; i++) {
bool active; int32 encoding;
if (m.FindInt32("encoding", i, &encoding) == B_OK &&
m.FindBool("active", i, &active) == B_OK &&
first_cjk_encoding <= encoding &&
encoding < first_cjk_encoding + no_of_cjk_encodings) {
SetCJKOrder(i, (font_encoding)encoding, active);
} else {
SetDefaultCJKOrder(); return;
}
}
return;
}
SetDefaultCJKOrder();
}
// --------------------------------------------------
BArchivable *Fonts::Instantiate(BMessage *archive)
{
if (!validate_instantiation(archive, "Fonts")) {
return NULL;
}
return new Fonts(archive);
}
// --------------------------------------------------
status_t Fonts::Archive(BMessage *archive, bool deep) const
{
archive->AddString("class", "Fonts");
const int n = Length();
for (int i = 0; i < n; i++) {
FontFile* f = At(i);
BMessage m;
if (f->Archive(&m) == B_OK) {
archive->AddMessage("fontfile", &m);
}
}
BMessage m;
font_encoding enc;
bool active;
for (int i = 0; GetCJKOrder(i, enc, active); i++) {
m.AddInt32("encoding", enc);
m.AddBool("active", active);
}
archive->AddMessage("cjk_order", &m);
return B_OK;
}
// --------------------------------------------------
status_t
Fonts::CollectFonts()
{
BPath path;
directory_which * which_dir;
directory_which lookup_dirs[] = {
B_SYSTEM_FONTS_DIRECTORY,
B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY,
B_USER_FONTS_DIRECTORY,
B_USER_NONPACKAGED_FONTS_DIRECTORY,
(directory_which) -1
};
which_dir = lookup_dirs;
while (*which_dir >= 0) {
if ( find_directory(*which_dir, &path) == B_OK )
LookupFontFiles(path);
which_dir++;
};
return B_OK;
}
// --------------------------------------------------
status_t
Fonts::LookupFontFiles(BPath path)
{
BDirectory dir(path.Path());
BEntry entry;
if (dir.InitCheck() != B_OK)
return B_ERROR;
dir.Rewind();
while (dir.GetNextEntry(&entry) >= 0) {
BPath name;
char fn[512];
font_type ft = unknown_type; // to keep the compiler silent.
off_t size;
status_t status;
entry.GetPath(&name);
if (entry.IsDirectory())
// recursivly lookup in sub-directories...
LookupFontFiles(name);
if (! entry.IsFile())
continue;
fn[0] = 0;
ft = unknown_type;
// is it a truetype file?
status = ttf_get_fontname(name.Path(), fn, sizeof(fn));
if (status == B_OK ) {
ft = true_type_type;
} else {
// okay, maybe it's a postscript type file?
status = psf_get_fontname(name.Path(), fn, sizeof(fn));
if (status == B_OK) {
ft = type1_type;
}
}
if (ft == unknown_type)
// not a font file...
continue;
if (entry.GetSize(&size) != B_OK)
size = 1024*1024*1024;
REPORT(kDebug, -1, "Installed font %s -> %s", fn, name.Path());
fFontFiles.AddItem(new FontFile(fn, name.Path(), size, ft, size < 100*1024));
} // while dir.GetNextEntry()...
return B_OK;
}
// --------------------------------------------------
void
Fonts::SetTo(BMessage *archive)
{
BArchivable *a = Instantiate(archive);
Fonts *f = a ? dynamic_cast<Fonts*>(a) : NULL;
if (f) {
const int n = Length();
const int m = f->Length();
for (int i = 0; i < m; i ++) {
FontFile *font = f->At(i);
for (int j = 0; j < n; j ++) {
if (strcmp(font->Path(), At(j)->Path()) == 0) {
At(j)->SetEmbed(font->Embed());
At(j)->SetSubst(font->Subst());
break;
}
}
}
font_encoding enc;
bool active;
for (int i = 0; f->GetCJKOrder(i, enc, active); i++) {
SetCJKOrder(i, enc, active);
}
delete f;
}
}
// --------------------------------------------------
static uint16 ttf_get_uint16(FILE * ttf)
{
uint16 v;
if (fread(&v, 1, 2, ttf) != 2)
return 0;
return B_BENDIAN_TO_HOST_INT16(v);
}
// --------------------------------------------------
static uint32 ttf_get_uint32(FILE *ttf)
{
uint32 buf;
if (fread(&buf, 1, 4, ttf) != 4)
return 0;
return B_BENDIAN_TO_HOST_INT32(buf);
}
// --------------------------------------------------
static status_t ttf_get_fontname(const char * path, char * fontname, size_t fn_size)
{
FILE * ttf;
status_t status;
uint16 nb_tables, nb_records;
uint16 i;
uint32 tag;
uint32 table_offset;
uint32 strings_offset;
char family_name[256];
char face_name[256];
int names_found;
status = B_ERROR;
ttf = fopen(path, "rb");
if (! ttf)
return status;
tag = ttf_get_uint32(ttf); /* version */
switch(tag) {
case TRUETYPE_VERSION:
case OPENTYPE_CFF_VERSION:
break;
default:
goto exit;
}
/* set up table directory */
nb_tables = ttf_get_uint16(ttf);
fseek(ttf, 12, SEEK_SET);
table_offset = 0; // quiet the compiler...
for (i = 0; i < nb_tables; ++i) {
tag = ttf_get_uint32(ttf);
ttf_get_uint32(ttf); // checksum
table_offset = ttf_get_uint32(ttf);
if (tag == TRUETTYPE_TABLE_NAME_TAG)
break;
}
if (tag != TRUETTYPE_TABLE_NAME_TAG)
// Mandatory name table not found!
goto exit;
// move to name table start
fseek(ttf, table_offset, SEEK_SET);
ttf_get_uint16(ttf); // name table format (must be 0!)
nb_records = ttf_get_uint16(ttf);
strings_offset = table_offset + ttf_get_uint16(ttf); // string storage offset is from table offset
// offs = ttf->dir[idx].offset + tp->offsetStrings;
// printf(" pid eid lid nid len offset value\n");
// 65536 65536 65536 65536 65536 65536 ......
family_name[0] = 0;
face_name[0] = 0;
names_found = 0;
for (i = 0; i < nb_records; ++i) {
uint16 platform_id, encoding_id, name_id;
uint16 string_len, string_offset;
platform_id = ttf_get_uint16(ttf);
encoding_id = ttf_get_uint16(ttf);
ttf_get_uint16(ttf); // language_id
name_id = ttf_get_uint16(ttf);
string_len = ttf_get_uint16(ttf);
string_offset = ttf_get_uint16(ttf);
if ( name_id != 1 && name_id != 2 )
continue;
// printf("%5d %5d %5d %5d %5d %5d ",
// platform_id, encoding_id, language_id, name_id, string_len, string_offset);
if (string_len != 0) {
long pos;
char * buffer;
pos = ftell(ttf);
fseek(ttf, strings_offset + string_offset, SEEK_SET);
buffer = (char *) malloc(string_len + 16);
fread(buffer, 1, string_len, ttf);
buffer[string_len] = '\0';
fseek(ttf, pos, SEEK_SET);
if ( (platform_id == 3 && encoding_id == 1) || // Windows Unicode
(platform_id == 0) ) { // Unicode
// dirty unicode -> ascii conversion
int k;
for (k=0; k < string_len/2; k++)
buffer[k] = buffer[2*k + 1];
buffer[k] = '\0';
}
// printf("%s\n", buffer);
if (name_id == 1)
strncpy(family_name, buffer, sizeof(family_name));
else if (name_id == 2)
strncpy(face_name, buffer, sizeof(face_name));
names_found += name_id;
free(buffer);
}
// else
// printf("<null>\n");
if (names_found == 3)
break;
}
if (names_found == 3) {
#ifndef __POWERPC__
snprintf(fontname, fn_size, "%s-%s", family_name, face_name);
#else
sprintf(fontname, "%s-%s", family_name, face_name);
#endif
status = B_OK;
}
exit:
fclose(ttf);
return status;
}
// --------------------------------------------------
static status_t psf_get_fontname(const char * path, char * fontname, size_t fn_size)
{
FILE * psf;
status_t status;
int i;
char line[1024];
char * token;
char * name;
// *.afm search for "FontName <font_name_without_blank>" line
// *.pfa search for "/FontName /<font_name_without_blank> def" line
status = B_ERROR;
psf = fopen(path, "r");
if (! psf)
return status;
name = NULL;
i = 0;
while ( fgets(line, sizeof(line), psf) != NULL ) {
i++;
if ( i > 64 )
// only check the first 64 lines of files...
break;
token = strtok(line, " \r\n");
if (! token)
continue;
if (strcmp(token, "FontName") == 0)
name = strtok(NULL, " \r\n");
else if (strcmp(token, "/FontName") == 0) {
name = strtok(NULL, " \r\n");
if (name)
name++; // skip the '/'
}
if (name)
break;
}
if (name) {
strncpy(fontname, name, fn_size);
status = B_OK;
}
fclose(psf);
return status;
}
// Implementation of UserDefinedEncodings
UserDefinedEncodings::UserDefinedEncodings()
: fCurrentEncoding(0)
, fCurrentIndex(0)
{
memset(fUsedMask, 0, sizeof(fUsedMask));
memset(fEncoding, 0, sizeof(fEncoding));
memset(fIndex, 0, sizeof(fIndex));
}
bool UserDefinedEncodings::Get(uint16 unicode, uint8 &encoding, uint8 &index) {
bool missing = !IsUsed(unicode);
if (missing) {
SetUsed(unicode);
fEncoding[unicode] = fCurrentEncoding; fIndex[unicode] = fCurrentIndex;
if (fCurrentIndex == 255) {
fCurrentIndex = 0; fCurrentEncoding ++;
} else {
fCurrentIndex ++;
}
}
encoding = fEncoding[unicode]; index = fIndex[unicode];
return missing;
}
@@ -1,172 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef FONTS_H
#define FONTS_H
#include <Archivable.h>
#include <String.h>
#include <List.h>
#include "PrintUtils.h"
enum font_encoding
{
macroman_encoding,
// TrueType
tt_encoding0,
tt_encoding1,
tt_encoding2,
tt_encoding3,
tt_encoding4,
// Type 1
t1_encoding0,
t1_encoding1,
t1_encoding2,
t1_encoding3,
t1_encoding4,
// CJK
japanese_encoding,
chinese_cns1_encoding,
chinese_gb1_encoding,
korean_encoding,
first_cjk_encoding = japanese_encoding,
no_of_cjk_encodings = korean_encoding - first_cjk_encoding + 1,
invalid_encoding = korean_encoding + 1,
user_defined_encoding_start
};
enum font_type
{
true_type_type,
type1_type,
unknown_type
};
class FontFile : public BArchivable
{
private:
BString fName;
BString fPath;
int64 fSize;
font_type fType;
bool fEmbed;
BString fSubst;
public:
FontFile() { }
FontFile(const char *n, const char *p, int64 s, font_type t, bool embed) : fName(n), fPath(p), fSize(s), fType(t), fEmbed(embed) { }
FontFile(BMessage *archive);
~FontFile() {};
static BArchivable* Instantiate(BMessage *archive);
status_t Archive(BMessage *archive, bool deep = true) const;
// accessors
const char* Name() const { return fName.String(); }
const char* Path() const { return fPath.String(); }
int64 Size() const { return fSize; }
font_type Type() const { return fType; }
bool Embed() const { return fEmbed; }
const char* Subst() const { return fSubst.String(); }
// setters
void SetEmbed(bool embed) { fEmbed = embed; }
void SetSubst(const char* subst) { fSubst = subst; }
};
class Fonts : public BArchivable {
private:
TList<FontFile> fFontFiles;
struct {
font_encoding encoding;
bool active;
} fCJKOrder[no_of_cjk_encodings];
status_t LookupFontFiles(BPath path);
public:
Fonts();
Fonts(BMessage *archive);
static BArchivable* Instantiate(BMessage *archive);
status_t Archive(BMessage *archive, bool deep = true) const;
status_t CollectFonts();
void SetTo(BMessage *archive);
FontFile* At(int i) const { return fFontFiles.ItemAt(i); }
int32 Length() const { return fFontFiles.CountItems(); }
void SetDefaultCJKOrder();
bool SetCJKOrder(int i, font_encoding enc, bool active);
bool GetCJKOrder(int i, font_encoding& enc, bool& active) const;
};
class UsedFont {
private:
BString fFamily;
BString fStyle;
float fSize;
public:
UsedFont(const char* family, const char* style, float size) : fFamily(family), fStyle(style), fSize(size) {}
const char* GetFamily() const { return fFamily.String(); }
const char* GetStyle() const { return fStyle.String(); }
float GetSize() const { return fSize; }
bool Equals(const char* family, const char* style, float size) const { return strcmp(GetFamily(), family) == 0 && strcmp(GetStyle(), style) == 0 && fSize == size; }
};
class UserDefinedEncodings {
public:
UserDefinedEncodings();
// returns true if new encoding and index pair
bool Get(uint16 unicode, uint8 &encoding, uint8 &index);
private:
bool IsUsed(uint16 unicode) const { return (fUsedMask[unicode / 8] & (1 << (unicode % 8))) != 0; }
void SetUsed(uint16 unicode) { fUsedMask[unicode / 8] |= 1 << (unicode % 8); }
uint8 fUsedMask[65536/8]; // exists an encoding and index for this code point?
uint8 fEncoding[65536]; // the encoding for each code point
uint8 fIndex[65536]; // the index for each code point
uint8 fCurrentEncoding;
uint8 fCurrentIndex;
};
#endif // FONTS_H
@@ -1,505 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <InterfaceKit.h>
#include <LayoutBuilder.h>
#include <SupportKit.h>
#include "BlockingWindow.h"
#include "FontsWindow.h"
#include "Fonts.h"
class CJKFontItem : public BStringItem
{
font_encoding fEncoding;
bool fActive;
public:
CJKFontItem(const char* label, font_encoding encoding, bool active = true);
void SetActive(bool active) { fActive = active; }
void DrawItem(BView* owner, BRect rect, bool drawEverything);
bool Active() const { return fActive; }
font_encoding Encoding() const { return fEncoding; }
};
CJKFontItem::CJKFontItem(const char* label, font_encoding encoding, bool active)
: BStringItem(label)
, fEncoding(encoding)
, fActive(active)
{
}
void
CJKFontItem::DrawItem(BView* owner, BRect rect, bool drawEverything)
{
BStringItem::DrawItem(owner, rect, drawEverything);
if (!fActive) {
owner->SetHighColor(0, 0, 0, 0);
float y = (rect.top + rect.bottom) / 2;
owner->StrokeLine(BPoint(rect.left, y), BPoint(rect.right, y));
}
}
static const char* FontName(font_encoding enc) {
switch(enc) {
case japanese_encoding: return "Japanese";
case chinese_cns1_encoding: return "Traditional Chinese";
case chinese_gb1_encoding: return "Simplified Chinese";
case korean_encoding: return "Korean";
default: return "invalid font encoding!";
}
}
// #pragma mark -- of DragListView
DragListView::DragListView(BRect frame, const char *name,
list_view_type type,
uint32 resizingMode, uint32 flags)
: BListView(frame, name, type, resizingMode, flags)
{
}
bool
DragListView::InitiateDrag(BPoint point, int32 index, bool wasSelected)
{
BMessage m;
DragMessage(&m, ItemFrame(index), this);
return true;
}
/**
* Constuctor
*
* @param
* @return
*/
FontsWindow::FontsWindow(Fonts *fonts)
: HWindow(BRect(0,0,400,220), "Fonts", B_TITLED_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
{
// ---- Ok, build a default page setup user interface
AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED));
fFonts = fonts;
BTabView* tabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
// --- Embedding tab ---
// add a *dialog* background
BView* embeddingPanel = new BView("Embedding", B_WILL_DRAW
| B_FRAME_EVENTS | B_NAVIGABLE_JUMP);
embeddingPanel->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
// add font list
#if USE_CLV
fList = new BColumnListView(BRect(),
"fonts_list", B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE_JUMP);
embeddingPanel->AddChild(fList);
#else
fList = new BListView("fonts_list", B_MULTIPLE_SELECTION_LIST);
BScrollView* embeddingScrollView = new BScrollView("scroll_list",
fList, 0, false, true);
fList->SetSelectionMessage(new BMessage(SELECTION_MSG));
#endif
FillFontList();
// add a "Embed" button, and make it default
fEmbedButton = new BButton("embed", "Embed", new BMessage(EMBED_MSG));
fEmbedButton->SetEnabled(false);
fEmbedButton->MakeDefault(true);
// add a "Substitute" button
fSubstButton = new BButton("substitute", "Substitute",
new BMessage(SUBST_MSG));
fSubstButton->SetEnabled(false);
embeddingScrollView->SetExplicitMinSize(BSize(200, 200));
BLayoutBuilder::Group<>(embeddingPanel, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(embeddingScrollView)
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add(fEmbedButton)
.Add(fSubstButton);
tabView->AddTab(embeddingPanel);
// --- CJK tab ---
// add a *dialog* background
BView* cjkPanel = new BView("CJK", B_WILL_DRAW | B_FRAME_EVENTS
| B_NAVIGABLE_JUMP);
cjkPanel->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BListView* list =
new DragListView(BRect(),
"cjk", B_MULTIPLE_SELECTION_LIST);
BScrollView* cjkScrollView = new BScrollView("cjk_scroll_list",
list, 0, false, true);
font_encoding enc; bool active;
for (int i = 0; fFonts->GetCJKOrder(i, enc, active); i++) {
list->AddItem(new CJKFontItem(FontName(enc), enc, active));
}
list->SetSelectionMessage(new BMessage(CJK_SELECTION_MSG));
fCJKList = list;
// add a "Embed" button
fEnableButton = new BButton("enable", "Enable", new BMessage(ENABLE_MSG));
fEnableButton->SetEnabled(false);
// add a "Disable" button
fDisableButton = new BButton("disable", "Disable",
new BMessage(DISABLE_MSG));
fDisableButton->SetEnabled(false);
// add a "Down" button
fDownButton = new BButton("down", "Down", new BMessage(DOWN_MSG));
fDownButton->SetEnabled(false);
// add a "Up" button
fUpButton = new BButton("up", "Up", new BMessage(UP_MSG));
fUpButton->SetEnabled(false);
BLayoutBuilder::Group<>(cjkPanel, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(cjkScrollView)
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add(fEnableButton)
.Add(fDisableButton)
.Add(fDownButton)
.Add(fUpButton);
tabView->AddTab(cjkPanel);
// add the tabView to the window
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(tabView);
MoveTo(320,320);
}
// --------------------------------------------------
FontsWindow::~FontsWindow()
{
}
// --------------------------------------------------
bool
FontsWindow::QuitRequested()
{
return true;
}
// --------------------------------------------------
void
FontsWindow::Quit()
{
inherited::Quit();
}
class ListIterator
{
virtual bool DoItem(BListItem* item) = 0;
public:
static bool DoIt(BListItem* item, void* data);
virtual ~ListIterator() {}
};
bool
ListIterator::DoIt(BListItem* item, void* data)
{
if (item->IsSelected()) {
ListIterator* e = (ListIterator*)data;
return e->DoItem(item);
}
return false;
}
class CountItems : public ListIterator
{
BListView* fList;
Fonts* fFonts;
int fNumEmbed;
int fNumSubst;
bool DoItem(BListItem* item);
public:
CountItems(BListView* list, Fonts* fonts);
int GetNumEmbed() { return fNumEmbed; }
int GetNumSubst() { return fNumSubst; }
};
CountItems::CountItems(BListView* list, Fonts* fonts)
: fList(list)
, fFonts(fonts)
, fNumEmbed(0)
, fNumSubst(0)
{ }
bool CountItems::DoItem(BListItem* item)
{
int32 i = fList->IndexOf(item);
if (0 <= i && i < fFonts->Length()) {
if (fFonts->At(i)->Embed()) {
fNumEmbed ++;
} else {
fNumSubst ++;
}
}
return false;
}
class EmbedFont : public ListIterator
{
FontsWindow* fWindow;
BListView* fList;
Fonts* fFonts;
bool fEmbed;
bool DoItem(BListItem* item);
public:
EmbedFont(FontsWindow* window, BListView* list, Fonts* fonts, bool embed);
};
EmbedFont::EmbedFont(FontsWindow* window, BListView* list, Fonts* fonts, bool embed)
: fWindow(window)
, fList(list)
, fFonts(fonts)
, fEmbed(embed)
{
}
bool
EmbedFont::DoItem(BListItem* item)
{
int32 i = fList->IndexOf(item);
if (0 <= i && i < fFonts->Length()) {
fFonts->At(i)->SetEmbed(fEmbed);
fWindow->SetItemText((BStringItem*)item, fFonts->At(i));
}
return false;
}
// move selected item in list one position up or down
void
FontsWindow::MoveItemInList(BListView* list, bool up)
{
int32 from = list->CurrentSelection(0);
if (from >= 0) {
int32 to;
if (up) {
if (from == 0) return; // at top of list
to = from - 1;
} else {
if (from == list->CountItems() -1) return; // at bottom of list
to = from + 1;
}
list->SwapItems(from, to);
font_encoding enc;
bool active;
fFonts->GetCJKOrder(from, enc, active);
font_encoding enc1;
bool active1;
fFonts->GetCJKOrder(to, enc1, active1);
fFonts->SetCJKOrder(to, enc, active);
fFonts->SetCJKOrder(from, enc1, active1);
}
}
void
FontsWindow::EnableItemInList(BListView* list, bool enable)
{
int32 i = list->CurrentSelection(0);
if (i >= 0) {
BListItem* item0 = list->ItemAt(i);
CJKFontItem* item = dynamic_cast<CJKFontItem*>(item0);
if (item) {
item->SetActive(enable);
list->Invalidate();
font_encoding enc;
bool active;
fFonts->GetCJKOrder(i, enc, active);
fFonts->SetCJKOrder(i, enc, enable);
}
}
}
// --------------------------------------------------
void
FontsWindow::MessageReceived(BMessage *msg)
{
switch (msg->what){
case OK_MSG: Quit();
break;
case CANCEL_MSG: Quit();
break;
case EMBED_MSG:
{
#if USE_CLV
#else
EmbedFont e(this, fList, fFonts, true);
fList->DoForEach(EmbedFont::DoIt, (void*)&e);
}
PostMessage(SELECTION_MSG);
fList->Invalidate();
#endif
break;
case SUBST_MSG:
{
#if USE_CLV
#else
EmbedFont e(this, fList, fFonts, false);
fList->DoForEach(EmbedFont::DoIt, (void*)&e);
}
PostMessage(SELECTION_MSG);
fList->Invalidate();
#endif
break;
case SELECTION_MSG:
{
CountItems count(fList, fFonts);
fList->DoForEach(CountItems::DoIt, (void*)&count);
fEmbedButton->SetEnabled(count.GetNumSubst() > 0);
fSubstButton->SetEnabled(count.GetNumEmbed() > 0);
}
break;
case UP_MSG:
case DOWN_MSG:
MoveItemInList(fCJKList, msg->what == UP_MSG);
PostMessage(CJK_SELECTION_MSG);
break;
case ENABLE_MSG:
case DISABLE_MSG:
EnableItemInList(fCJKList, msg->what == ENABLE_MSG);
PostMessage(CJK_SELECTION_MSG);
break;
case CJK_SELECTION_MSG:
{
int32 i = fCJKList->CurrentSelection(0);
if (i >= 0) {
BListItem* item0 = fCJKList->ItemAt(i);
CJKFontItem* item = dynamic_cast<CJKFontItem*>(item0);
if (item) {
fUpButton->SetEnabled(i != 0);
fDownButton->SetEnabled(i != fCJKList->CountItems()-1);
fEnableButton->SetEnabled(!item->Active());
fDisableButton->SetEnabled(item->Active());
}
}
}
break;
default:
inherited::MessageReceived(msg);
break;
}
}
void
FontsWindow::SetItemText(BStringItem* i, FontFile* f)
{
const int64 KB = 1024;
const int64 MB = KB * KB;
char buffer[40];
BString s;
s << f->Name() << ": ";
if (f->Type() == true_type_type) s << "TrueType";
else s << "Type 1";
s << " (";
if (f->Size() >= MB) {
sprintf(buffer, "%d MB", (int)(f->Size()/MB));
} else if (f->Size() >= KB) {
sprintf(buffer, "%d KB", (int)(f->Size()/KB));
} else {
sprintf(buffer, "%d B", (int)(f->Size()));
}
s << buffer;
s << ") ";
s << (f->Embed() ? "embed" : "substitute");
i->SetText(s.String());
}
void
FontsWindow::FillFontList()
{
const int n = fFonts->Length();
for (int i = 0; i < n; i++) {
#if USE_CLV
#else
BStringItem* s;
FontFile* f = fFonts->At(i);
fList->AddItem(s = new BStringItem(""));
SetItemText(s, f);
#endif
}
}
void
FontsWindow::EmptyFontList()
{
#if USE_CLV
#else
const int n = fList->CountItems();
for (int i = 0; i < n; i++) {
BListItem* item = fList->ItemAt(i);
delete item;
}
fList->MakeEmpty();
#endif
}
@@ -1,118 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef FONTSWINDOW_H
#define FONTSWINDOW_H
#include <InterfaceKit.h>
#include <Message.h>
#include <Messenger.h>
#include <File.h>
#include <FindDirectory.h>
#include <Path.h>
#include <String.h>
#include "PrintUtils.h"
#include "Fonts.h"
#define USE_CLV 0
#if USE_CLV
#include "ColumnListView.h"
#endif
class DragListView : public BListView
{
public:
DragListView(BRect frame, const char *name,
list_view_type type = B_SINGLE_SELECTION_LIST,
uint32 resizingMode = B_FOLLOW_ALL,
uint32 flags = B_WILL_DRAW | B_NAVIGABLE | B_FRAME_EVENTS);
bool InitiateDrag(BPoint point, int32 index, bool wasSelected);
};
class FontsWindow : public HWindow
{
public:
// Constructors, destructors, operators...
FontsWindow(Fonts* fonts);
~FontsWindow();
typedef HWindow inherited;
// public constantes
enum {
OK_MSG = 'ok__',
CANCEL_MSG = 'cncl',
EMBED_MSG = 'mbed',
SUBST_MSG = 'subs',
SELECTION_MSG = 'sele',
CJK_SELECTION_MSG = 'cjks',
UP_MSG = 'up__',
DOWN_MSG = 'down',
ENABLE_MSG = 'enbl',
DISABLE_MSG = 'dsbl',
};
// Virtual function overrides
public:
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
void Quit();
private:
Fonts* fFonts;
#if USE_CLV
BColumnListView fList;
#else
BListView* fList;
#endif
BButton* fEmbedButton;
BButton* fSubstButton;
BListView* fCJKList;
BButton* fUpButton;
BButton* fDownButton;
BButton* fEnableButton;
BButton* fDisableButton;
void FillFontList();
void EmptyFontList();
void SetItemText(BStringItem* i, FontFile* f);
void MoveItemInList(BListView* list, bool up);
void EnableItemInList(BListView* list, bool enable);
friend class EmbedFont;
};
#endif
@@ -1,194 +0,0 @@
/*
Image Cache Item.
Copyright (c) 2003 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <unistd.h>
#include <sys/stat.h>
#include <File.h>
#include <Translator.h>
#include <TranslationUtils.h>
#include <TranslatorRoster.h>
#include <BitmapStream.h>
#include <Debug.h>
#include <Message.h>
#include "Report.h"
#include "Image.h"
#include "ImageCache.h"
// Implementation of ImageDescription
ImageDescription::ImageDescription(PDF* pdf, BBitmap* bitmap, int mask)
: fPDF(pdf)
, fBitmap(bitmap)
, fMask(mask)
{
bitmap->Lock();
fWidth = bitmap->Bounds().IntegerWidth()+1;
fHeight = bitmap->Bounds().IntegerHeight()+1;
fColorSpace = bitmap->ColorSpace();
bitmap->Unlock();
}
CacheItem* ImageDescription::NewItem(int id) {
REPORT(kDebug, -1, "ImageDescription::NewItem %d", id);
Image* image = Store(fPDF, id, fBitmap, fMask);
if (image == NULL) {
REPORT(kDebug, -1, "Could not store image in cache!");
}
return image;
}
Image* ImageDescription::Store(PDF* pdf, int id, BBitmap* bitmap, int mask) {
BString fileName(kImagePathPrefix);
BString pdfFileName;
int w, h;
color_space cs;
fileName << id;
pdfFileName = fileName;
pdfFileName << ".png";
bitmap->Lock();
w = bitmap->Bounds().IntegerWidth()+1;
h = bitmap->Bounds().IntegerHeight()+1;
cs = bitmap->ColorSpace();
bitmap->Unlock();
#if STORE_AS_BBITMAP
fileName << ".bitmap";
#else
fileName << ".png";
#endif
if (!StorePNG(pdfFileName.String(), bitmap)) {
REPORT(kError, -1, "Image cache could not store image as PNG file.");
return NULL;
}
if (!StoreBitmap(fileName.String(), bitmap)) {
REPORT(kError, -1, "Image cache could not store image as flattend BBitmap.");
unlink(pdfFileName.String());
return NULL;
}
int image;
image = PDF_open_image_file(pdf, "png", pdfFileName.String(),
mask == -1 ? "" : "masked", mask == -1 ? 0 : mask);
#if STORE_AS_BBITMAP
unlink(pdfFileName.String());
#endif
if (image < 0) {
REPORT(kError, -1, "Image cache could not embed image.");
return NULL;
}
return new Image(pdf, image, fileName.String(), w, h, cs, mask);
}
bool ImageDescription::StorePNG(const char* fileName, BBitmap* bitmap) {
bool ok = true;
BTranslatorRoster *roster = BTranslatorRoster::Default();
BBitmapStream stream(bitmap); // init with contents of bitmap
BFile file(fileName, B_CREATE_FILE | B_WRITE_ONLY | B_ERASE_FILE);
ok = roster->Translate(&stream, NULL, NULL, &file, B_PNG_FORMAT) == B_OK;
BBitmap *bm = NULL; stream.DetachBitmap(&bm); // otherwise bitmap destructor crashes here!
ASSERT(bm == bitmap);
return ok;
}
bool ImageDescription::StoreBitmap(const char* fileName, BBitmap* bitmap) {
bool ok = true;
#if STORE_AS_BBITMAP
BMessage msg;
BFile file(fileName, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
ok = file.InitCheck() == B_OK && bitmap->Archive(&msg) == B_OK && msg.Flatten(&file) == B_OK;
#endif
return ok;
}
// Implementation of Image
Image::Image(PDF* pdf, int imageID, const char* fileName, int width, int height, color_space colorSpace, int mask)
: fPDF(pdf)
, fImageID(imageID)
, fFileName(fileName)
, fWidth(width)
, fHeight(height)
, fColorSpace(colorSpace)
, fMask(mask)
{
}
Image::~Image() {
PDF_close_image(fPDF, ImageID());
unlink(FileName());
}
bool Image::Equals(CIDescription* description) const {
REPORT(kDebug, -1, "Image::Equals called.");
ImageDescription* desc = dynamic_cast<ImageDescription*>(description);
ASSERT(desc != NULL);
if (desc->Width() != Width() || desc->Height() != Height() ||
desc->ColorSpace() != ColorSpace() ||
desc->Mask() != Mask()) return false;
return Equals(desc->Bitmap());
}
bool Image::Equals(BBitmap* bitmap) const {
REPORT(kDebug, -1, "Image::Equals called.");
bool equals = false;
BBitmap* bm = NULL;
#if STORE_AS_BBITMAP
BMessage msg;
BFile file(FileName(), B_READ_ONLY);
if (file.InitCheck() == B_OK && msg.Unflatten(&file) == B_OK) {
BArchivable* a = BBitmap::Instantiate(&msg);
bm = dynamic_cast<BBitmap*>(a);
if (bm == NULL && a != NULL) delete a;
}
#else
bm = BTranslationUtils::GetBitmapFile(FileName());
#endif
if (bm) {
bm->Lock();
bitmap->Lock();
equals = bm->BitsLength() == bitmap->BitsLength() &&
bm->ColorSpace() == bitmap->ColorSpace() &&
memcmp(bm->Bits(), bitmap->Bits(), bm->BitsLength()) == 0;
bitmap->Unlock();
bm->Unlock();
delete bm;
} else {
REPORT(kError, -1, "Could not load image from cache!");
}
return equals;
}
@@ -1,91 +0,0 @@
/*
Image Cache Item.
Copyright (c) 2003 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _IMAGE_CACHE_ITEM_H
#define _IMAGE_CACHE_ITEM_H
#include "pdflib.h"
#include <Bitmap.h>
#include "pdflib.h"
#include "PrintUtils.h"
#include "Cache.h"
class Image;
class ImageDescription : public CIDescription {
public:
ImageDescription(PDF* pdf, BBitmap* bitmap, int mask);
CacheItem* NewItem(int id);
BBitmap* Bitmap() { return fBitmap; }
int Width() const { return fWidth; }
int Height() const { return fHeight; }
color_space ColorSpace() const { return fColorSpace; }
int Mask() const { return fMask; }
private:
Image* Store(PDF* pdf, int id, BBitmap* bitmap, int mask);
bool StoreBitmap(const char* fileName, BBitmap* bitmap);
bool StorePNG(const char* fileName, BBitmap* bitmap);
PDF* fPDF;
BBitmap* fBitmap;
int fWidth, fHeight;
color_space fColorSpace;
int fMask;
};
class Image : public CacheItem {
public:
Image(PDF* pdf, int imageID, const char* fileName, int width, int height, color_space colorSpace, int mask);
~Image();
int ImageID() const { return fImageID; };
const char* FileName() const { return fFileName.String(); };
int Width() const { return fWidth; };
int Height() const { return fHeight; };
color_space ColorSpace() const { return fColorSpace; };
int Mask() const { return fMask; };
bool Equals(CIDescription* desc) const;
bool Equals(BBitmap* bitmap) const;
private:
PDF* fPDF;
int fImageID;
BString fFileName;
int fWidth, fHeight;
color_space fColorSpace;
int fMask;
};
#endif
@@ -1,99 +0,0 @@
/*
Image Cache.
Copyright (c) 2003 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <unistd.h>
#include <Debug.h>
#include <OS.h>
#include "Report.h"
#include "ImageCache.h"
#include "Image.h"
#include "Mask.h"
const char* kTemporaryPath = "/tmp/PDFWriter";
const char* kCachePath = NULL;
const char* kImagePathPrefix = NULL;
const char* kMaskPathPrefix = NULL;
// Implementation of ImageCache
ImageCache::ImageCache()
{
BString path(kTemporaryPath);
path << "/Cache" << (int)find_thread(NULL);
kCachePath = strdup(path.String());
BString path2(path);
path += "/Image";
kImagePathPrefix = strdup(path.String());
path2 += "/Mask";
kMaskPathPrefix = strdup(path2.String());
mkdir(kTemporaryPath, 0777);
mkdir(kCachePath, 0777);
}
ImageCache::~ImageCache() {
rmdir(kCachePath);
free((void*)kCachePath);
free((void*)kImagePathPrefix);
free((void*)kMaskPathPrefix);
}
void ImageCache::Flush() {
fImageCache.MakeEmpty();
fMaskCache.MakeEmpty();
}
void ImageCache::NextPass() {
fImageCache.NextPass();
fMaskCache.NextPass();
}
int ImageCache::GetImage(PDF* pdf, BBitmap* bitmap, int mask) {
ImageDescription desc(pdf, bitmap, mask);
CacheItem* item = fImageCache.Find(&desc);
Image* image = dynamic_cast<Image*>(item);
if (image) {
return image->ImageID();
}
REPORT(kError, -1, "Image cache could not find image. Please make sure to have enough disk space available.");
return -1;
}
int ImageCache::GetMask(PDF* pdf, const char* mask, int length, int width, int height, int bpc) {
MaskDescription desc(pdf, mask, length, width, height, bpc);
CacheItem* item = fMaskCache.Find(&desc);
Mask* image = dynamic_cast<Mask*>(item);
if (image) {
return image->ImageID();
}
REPORT(kError, -1, "Mask cache could not find image. Please make sure to have enough disk space available.");
return -1;
}
@@ -1,64 +0,0 @@
/*
Image Cache.
Copyright (c) 2003 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _IMAGE_CACHE_H
#define _IMAGE_CACHE_H
#include <Bitmap.h>
#include <InterfaceDefs.h>
#include <String.h>
#include "pdflib.h"
#include "PrintUtils.h"
#include "Cache.h"
extern const char* kTemporaryPath;
extern const char* kCachePath;
extern const char* kImagePathPrefix;
extern const char* kMaskPathPrefix;
#define STORE_AS_BBITMAP 1
class ImageCache {
public:
ImageCache();
~ImageCache();
void Flush();
void NextPass();
int GetImage(PDF* pdf, BBitmap* bitmap, int mask);
int GetMask(PDF* pdf, const char* mask, int length, int width, int height, int bpc);
private:
Cache fImageCache;
Cache fMaskCache;
};
#endif
@@ -1,52 +0,0 @@
SubDir HAIKU_TOP src add-ons print drivers pdf source ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders print ;
SubDirHdrs [ FDirName $(HAIKU_TOP) headers libs print libprint ] ;
SubDirHdrs [ FDirName $(HAIKU_TOP) src libs pdflib libs pdflib ] ;
AddResources PDF\ Writer :
PDFWriter.rdef
;
Addon PDF\ Writer :
AboutText.cpp
AdvancedSettingsWindow.cpp
Bezier.cpp
Bookmark.cpp
Cache.cpp
DocInfoWindow.cpp
DrawShape.cpp
Driver.cpp
Fonts.cpp
FontsWindow.cpp
Image.cpp
ImageCache.cpp
JobSetupWindow.cpp
LinePathBuilder.cpp
Link.cpp
Mask.cpp
PDFLinePathBuilder.cpp
PDFText.cpp
PDFWriter.cpp
PageSetupWindow.cpp
PictureIterator.cpp
PrinterDriver.cpp
PrinterPrefs.cpp
PrinterSettings.cpp
RegExp.cpp
Report.cpp
Scanner.cpp
StatusWindow.cpp
SubPath.cpp
XReferences.cpp
:
be
textencoding
translation
libpdf.a
libprint.a
libprintutils.a
[ TargetLibsupc++ ]
;
@@ -1,250 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001-2003 OpenBeOS.
Copyright (c) 2010 Haiku, Inc.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <GridView.h>
#include <InterfaceKit.h>
#include <LayoutBuilder.h>
#include <SeparatorView.h>
#include <SupportKit.h>
#include <stdlib.h>
#include "PrintUtils.h"
#include "PrinterDriver.h"
#include "JobSetupWindow.h"
#include "DocInfoWindow.h"
static const char* includeKeys[] = {
"doc_info",
#if HAVE_FULLVERSION_PDF_LIB
"master_password", "user_password", "permissions",
#endif
NULL
};
// --------------------------------------------------
JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
: HWindow(BRect(0, 0, 100, 100), "Job setup",
B_TITLED_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
{
fSetupMsg = msg;
fExitSem = create_sem(0, "JobSetup");
fResult = B_ERROR;
if (printerName) {
BString title;
title << printerName << " job setup";
SetTitle(title.String());
fPrinterName = printerName;
}
// PrinterDriver ensures that property exists
int32 firstPage;
fSetupMsg->FindInt32("first_page", &firstPage);
int32 lastPage;
fSetupMsg->FindInt32("last_page", &lastPage);
BMessage doc_info;
if (fSetupMsg->FindMessage("doc_info", &doc_info) != B_OK) {
// default fields
doc_info.AddString("Author", "");
doc_info.AddString("Subject", "");
doc_info.AddString("Keywords", "");
fSetupMsg->AddMessage("doc_info", &doc_info);
}
AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys);
bool allPages = firstPage == 1 && lastPage == MAX_INT32;
fAll = new BRadioButton("allPages", "Print all pages",
new BMessage(ALL_PAGES_MGS));
fAll->SetValue(allPages);
fRange = new BRadioButton("pagesRange", "Print pages:",
new BMessage(RANGE_SELECTION_MSG));
fRange->SetValue(!allPages);
fFrom = new BTextControl("from", "From:", "SomeSpaceHere", NULL);
fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
fFrom->SetEnabled(!allPages);
fTo = new BTextControl("to", "To:", "", NULL);
fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
fTo->SetEnabled(!allPages);
BString buffer;
buffer << firstPage;
fFrom->SetText(buffer.String());
buffer = "";
buffer << lastPage;
fTo->SetText(buffer.String());
for (uint32 i = 0; i < '0'; i++) {
fTo->TextView()->DisallowChar(i);
fFrom->TextView()->DisallowChar(i);
}
for (uint32 i = '9' + 1; i < 255; i++) {
fTo->TextView()->DisallowChar(i);
fFrom->TextView()->DisallowChar(i);
}
BButton* documentInfo = new BButton("documentInfo",
"Document" B_UTF8_ELLIPSIS,
new BMessage(DOC_INFO_MSG));
BButton* cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG));
BButton* ok = new BButton("ok", "OK", new BMessage(OK_MSG));
ok->MakeDefault(true);
BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_SMALL_SPACING)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(fAll)
.Add(fRange)
.AddGrid(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING)
.SetInsets(B_USE_SMALL_SPACING, 0, B_USE_SMALL_SPACING, 0)
.Add(fFrom->CreateLabelLayoutItem(), 0, 0)
.Add(fFrom->CreateTextViewLayoutItem(), 1, 0)
.Add(fTo->CreateLabelLayoutItem(), 0, 1)
.Add(fTo->CreateTextViewLayoutItem(), 1, 1)
.End()
.AddGlue()
.Add(new BSeparatorView(B_HORIZONTAL, B_FANCY_BORDER))
.AddGroup(B_HORIZONTAL)
.Add(documentInfo)
.AddGlue()
.Add(cancel)
.Add(ok)
.End();
}
// --------------------------------------------------
void
JobSetupWindow::UpdateJobMessage()
{
int32 copies = 1;
int32 from;
int32 to;
if (fAll->Value() == B_CONTROL_ON) {
from = 1; to = MAX_INT32;
} else {
from = atoi(fFrom->Text());
to = atoi(fTo->Text());
if (from <= 0) from = 1;
if (to < from) to = from;
}
fSetupMsg->ReplaceInt32("copies", copies);
fSetupMsg->ReplaceInt32("first_page", from);
fSetupMsg->ReplaceInt32("last_page", to);
AddFields(fSetupMsg, &fDocInfo);
}
// --------------------------------------------------
JobSetupWindow::~JobSetupWindow()
{
delete_sem(fExitSem);
}
// --------------------------------------------------
bool
JobSetupWindow::QuitRequested()
{
release_sem(fExitSem);
return true;
}
// --------------------------------------------------
void
JobSetupWindow::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case OK_MSG:
UpdateJobMessage();
fResult = B_OK;
release_sem(fExitSem);
break;
case CANCEL_MSG:
release_sem(fExitSem);
break;
case ALL_PAGES_MGS:
fTo->SetEnabled(false);
fFrom->SetEnabled(false);
break;
case RANGE_SELECTION_MSG:
fTo->SetEnabled(true);
fFrom->SetEnabled(true);
break;
case DOC_INFO_MSG:
(new DocInfoWindow(&fDocInfo))->Show();
break;
default:
inherited::MessageReceived(msg);
break;
}
}
// --------------------------------------------------
status_t
JobSetupWindow::Go()
{
MoveTo(300,300);
Show();
while (acquire_sem(fExitSem) == B_INTERRUPTED) {
}
// Cache the value as after Quit() this object is deleted.
status_t result = fResult;
if (Lock())
Quit();
return result;
}
@@ -1,83 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef JOBSETUPWINDOW_H
#define JOBSETUPWINDOW_H
#include <InterfaceKit.h>
#include "BlockingWindow.h"
#include "PrintUtils.h"
class JobSetupWindow : public HWindow
{
public:
// Constructors, destructors, operators...
JobSetupWindow(BMessage *msg, const char *printer_name = NULL);
~JobSetupWindow();
typedef HWindow inherited;
// public constantes
enum {
NB_COPIES_MSG = 'copy',
ALL_PAGES_MGS = 'all_',
RANGE_SELECTION_MSG = 'rnge',
RANGE_FROM_MSG = 'from',
RANGE_TO_MSG = 'to__',
OK_MSG = 'ok__',
CANCEL_MSG = 'cncl',
DOC_INFO_MSG = 'doci'
};
// Virtual function overrides
public:
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
status_t Go();
// From here, it's none of your business! ;-)
private:
BString fPrinterName;
long fExitSem;
status_t fResult;
BMessage *fSetupMsg;
BMessage fDocInfo;
BRadioButton *fAll;
BRadioButton *fRange;
BTextControl *fFrom;
BTextControl *fTo;
void UpdateJobMessage();
};
#endif
@@ -1,341 +0,0 @@
/*
LinePathBuilder
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <math.h>
#include "LinePathBuilder.h"
#include <math.h>
static const float kNearZero = 0.000000000001;
static const float kMinPenSize = 0.0001;
LinePathBuilder::LinePathBuilder(SubPath *subPath, float penSize, cap_mode capMode, join_mode joinMode, float miterLimit)
: fSubPath(subPath)
, fPenSize(penSize)
, fCapMode(capMode)
, fJoinMode(joinMode)
, fMiterLimit(miterLimit)
, fFirst(true)
{
}
// vector of length w/2 in direction of line [a, b]
bool
LinePathBuilder::Vector(BPoint a, BPoint b, float w, BPoint &v)
{
v = b - a;
float l = 2.0 * sqrt(v.x * v.x + v.y * v.y);
if (fabs(l) <= kNearZero) return false;
w /= l;
v.x *= w;
v.y *= w;
return true;
}
// calculate line [pa, pb] parallel to line [a, b] in distance of w/2
bool
LinePathBuilder::Parallel(BPoint a, BPoint b, float w, BPoint &pa, BPoint &pb)
{
BPoint d;
if (!Vector(a, b, w, d)) return false;
BPoint r(-d.y, d.x);
pa = a - r;
pb = b - r;
return true;
}
// calculate intercept point e of lines [a, b] and [c, d]
bool
LinePathBuilder::Cut(BPoint a, BPoint b, BPoint c, BPoint d, BPoint &e)
{
BPoint r = b - a;
BPoint s = d - c;
BPoint v = c - a;
float div = r.x * s.y - r.y * s.x;
if (fabs(div) <= kNearZero) return false;
float u = (r.y * v.x - r.x * v.y) / div;
e.x = c.x + s.x * u;
e.y = c.y + s.y * u;
return true;
}
void
LinePathBuilder::RoundCap(BPoint a, BPoint b, BPoint ra, BPoint rb, bool start)
{
BPoint bezier[3];
BPoint v;
if (start) { // first quarter circle
Vector(b, a, PenSize(), v);
BPoint v055(0.55*v.x, 0.55*v.y);
BPoint vr055(-v.y, v.x);
bezier[0] = a + v + vr055;
bezier[1] = ra + v055;
bezier[2] = ra;
AddPoint(a+v);
BezierTo(bezier);
} else { // second quarter circle
Vector(a, b, PenSize(), v);
BPoint v055(0.55*v.x, 0.55*v.y);
BPoint vr055(v.y, -v.x);
bezier[0] = rb + v055;
bezier[1] = b + v + vr055;
bezier[2] = b + v;
AddPoint(rb);
BezierTo(bezier);
}
}
void
LinePathBuilder::Corner(BPoint a, BPoint b, bool start)
{
BPoint ra, rb, r;
if (Parallel(a, b, PenSize(), ra, rb)) {
BPoint v;
switch (LineCapMode()) {
case B_ROUND_CAP:
RoundCap(a, b, ra, rb, start);
return;
case B_BUTT_CAP: // nothing to do
break;
case B_SQUARE_CAP:
Vector(a, b, PenSize(), v);
ra -= v;
rb += v;
break;
}
if (start) r = ra; else r = rb;
AddPoint(r);
}
}
bool
LinePathBuilder::Inside(BPoint a, BPoint b, BPoint r)
{
BPoint v;
Vector(a, b, 2.0, v);
if (kNearZero <= fabs(v.x)) return (r.x - b.x) / v.x <= 0.0;
else if (kNearZero <= fabs(v.y)) return (r.y - b.y) / v.y <= 0.0;
else return false; // should not reach here (length of v > 0.0!)
}
bool
LinePathBuilder::InMiterLimit(BPoint a, BPoint b)
{
BPoint d = a - b;
return 2.0*sqrt(d.x*d.x + d.y*d.y)/PenSize() <= LineMiterLimit();
}
void
LinePathBuilder::RoundJoin(BPoint p[4])
{
BPoint v[2];
Vector(p[0], p[1], PenSize() * 0.63, v[0]);
Vector(p[3], p[2], PenSize() * 0.63, v[1]);
AddPoint(p[1]);
BPoint bezier[3] = {p[1]+v[0], p[2]+v[1], p[2] };
BezierTo(bezier);
}
void
LinePathBuilder::Connect(BPoint a, BPoint b, BPoint c)
{
BPoint p[4], r, v;
if (Parallel(a, b, PenSize(), p[0], p[1]) &&
Parallel(b, c, PenSize(), p[2], p[3]) &&
Cut(p[0], p[1], p[2], p[3], r)) {
if (LineJoinMode() != B_BUTT_JOIN &&
LineJoinMode() != B_SQUARE_JOIN &&
Inside(p[0], p[1], r)) {
if (!Inside(p[1], p[0], r) || !Inside(p[2], p[3], r)) {
AddPoint(p[1]); AddPoint(p[2]);
} else {
AddPoint(r);
}
return;
}
switch (LineJoinMode()) {
case B_ROUND_JOIN:
RoundJoin(p);
break;
case B_MITER_JOIN:
if (InMiterLimit(b, r)) {
AddPoint(r);
break;
}
// fall through
case B_BEVEL_JOIN:
AddPoint(p[1]); AddPoint(p[2]);
break;
case B_BUTT_JOIN: // ???
AddPoint(p[1]); AddPoint(b); AddPoint(p[2]);
break;
case B_SQUARE_JOIN: // ???
Vector(a, b, PenSize(), v);
AddPoint(p[1] + v); AddPoint(b + v);
Vector(b, c, PenSize(), v);
AddPoint(b - v); AddPoint(p[2] - v);
break;
}
}
}
bool
LinePathBuilder::IdenticalPoints(int i, int j)
{
BPoint d = fSubPath->PointAt(i) - fSubPath->PointAt(j);
return d.x * d.x + d.y * d.y < kNearZero;
}
// remove identical points
void
LinePathBuilder::OptimizeSubPath()
{
int i, j = 0;
const int n = fSubPath->CountPoints();
for (i = 1; i < n; i++) {
if (!IdenticalPoints(i, j)) {
fSubPath->AtPut(++j, fSubPath->PointAt(i));
}
}
fSubPath->Truncate(i-j-1);
// check also first point == last point if path is closed
if (fSubPath->IsClosed() && fSubPath->CountPoints() >= 2) {
const int n = fSubPath->CountPoints()-1;
if (IdenticalPoints(0, n)) fSubPath->Truncate(1);
}
}
BPoint
LinePathBuilder::PointAt(int i)
{
const int n = fSubPath->CountPoints();
return fSubPath->PointAt((i+n) % n);
}
void
LinePathBuilder::AddPoint(BPoint p)
{
if (fFirst) {
fFirst = false;
MoveTo(p);
} else {
LineTo(p);
}
}
void
LinePathBuilder::CreateLinePath()
{
OptimizeSubPath();
if (fPenSize < kMinPenSize) fPenSize = kMinPenSize;
const bool start = true;
const bool end = false;
const int n = fSubPath->CountPoints();
if (n < 2) return;
bool is_closed = fSubPath->IsClosed() && n != 2;
if (fSubPath->IsClosed() && n == 2) {
switch (LineJoinMode()) {
case B_ROUND_JOIN:
fCapMode = B_ROUND_CAP;
break;
case B_MITER_JOIN: // fall through
case B_BEVEL_JOIN: // fall through
case B_BUTT_JOIN:
fCapMode = B_BUTT_CAP;
break;
case B_SQUARE_JOIN:
fCapMode = B_SQUARE_CAP;
break;
}
}
// ahead
if (is_closed) {
Connect(PointAt(n-1), PointAt(0), PointAt(1));
} else {
Corner(PointAt(0), PointAt(1), start);
}
for (int i = 1; i < n-1; i++) {
Connect(PointAt(i-1), PointAt(i), PointAt(i+1));
}
if (is_closed) {
Connect(PointAt(n-2), PointAt(n-1), PointAt(n));
Connect(PointAt(n-1), PointAt(n), PointAt(n+1));
} else {
Corner(PointAt(n-2), PointAt(n-1), end);
}
// and back
if (is_closed) {
ClosePath(); fFirst = true;
Connect(PointAt(n+1), PointAt(n), PointAt(n-1));
Connect(PointAt(n), PointAt(n-1), PointAt(n-2));
} else {
Corner(PointAt(n-1), PointAt(n-2), start);
}
for (int i = n-2; i >= 1; i--) {
Connect(PointAt(i+1), PointAt(i), PointAt(i-1));
}
if (is_closed) {
Connect(PointAt(1), PointAt(0), PointAt(n-1));
} else {
Corner(PointAt(1), PointAt(0), end);
}
ClosePath();
}
@@ -1,81 +0,0 @@
/*
LinePathBuilder
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef LINE_PATH_BUILDER_H
#define LINE_PATH_BUILDER_H
#include "SubPath.h"
#include <InterfaceDefs.h>
class LinePathBuilder
{
SubPath *fSubPath;
float fPenSize;
cap_mode fCapMode;
join_mode fJoinMode;
float fMiterLimit;
bool fFirst;
float PenSize() const { return fPenSize; }
cap_mode LineCapMode() const { return fCapMode; }
join_mode LineJoinMode() const { return fJoinMode; }
float LineMiterLimit() const { return fMiterLimit; }
bool Vector(BPoint a, BPoint b, float w, BPoint &v);
bool Parallel(BPoint a, BPoint b, float w, BPoint &pa, BPoint &pb);
bool Cut(BPoint a, BPoint b, BPoint c, BPoint d, BPoint &e);
bool Inside(BPoint a, BPoint b, BPoint r);
bool InMiterLimit(BPoint a, BPoint b);
void RoundCap(BPoint a, BPoint b, BPoint ra, BPoint rb, bool start);
void RoundJoin(BPoint p[4]);
void AddPoint(BPoint p);
void Corner(BPoint a, BPoint b, bool start);
void Connect(BPoint a, BPoint b, BPoint c);
bool IdenticalPoints(int i, int j);
void OptimizeSubPath();
BPoint PointAt(int i);
protected:
virtual void MoveTo(BPoint p) = 0;
virtual void LineTo(BPoint p) = 0;
virtual void BezierTo(BPoint p[3]) = 0;
virtual void ClosePath(void) = 0;
public:
LinePathBuilder(SubPath *subPath, float penSize, cap_mode capMode, join_mode joinMode, float miterLimit);
virtual ~LinePathBuilder() { }
virtual void CreateLinePath();
};
#endif
@@ -1,476 +0,0 @@
/*
Detection and adding of web links.
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <Debug.h>
#include <ctype.h>
#include "Link.h"
#include "XReferences.h"
#include "Bookmark.h"
#include "PDFSystem.h"
#include "PDFWriter.h"
#include "Log.h"
#include "Report.h"
Link::Link(PDFWriter* writer, BString* utf8)
: fWriter(writer)
, fUtf8(utf8)
, fContainsLink(false)
{
}
bool
Link::BoundingBox(BRect* rect) {
return fWriter->fTextLine.BoundingBox(fStartPos, fEndPos+1, rect);
}
// create link from fStartPos to fEndPos and fStart to end
void
Link::CreateLink()
{
static bool reported = false; // report warning once only
BRect bounds;
if (BoundingBox(&bounds)) {
CreateLink(bounds.left, bounds.bottom, bounds.right, bounds.top);
} else if (!reported) {
REPORT(kWarning, fWriter->fPage, "Warning: Can not create link for rotated font!");
reported = true;
}
}
void
Link::Do() {
int pos = 0;
do {
DetectLink(pos);
if (ContainsLink()) {
CreateLink();
pos = fEndPos;
}
} while (ContainsLink());
}
// TODO: check this list and add more prefixes
const char* WebLink::fURLPrefix[] = {
"http://",
"https://",
"ftp://",
"telnet://",
"mailto:",
"news://",
"nntp://",
"gopher://",
"wais://",
"prospero://",
"mid:",
"cid:",
"afs://",
NULL
};
// Superset of xpalphas rule in BNF for specific URL schemes
// See: http://www.w3.org/Addressing/URL/5_BNF.html
bool
WebLink::IsValidCodePoint(const char* cp, int cps) {
if (cps == 1) {
char c = *cp;
switch (c) {
// safe
case '$': case '-': case '_': case '@':
case '.': case '&': case '+':
// extra
case '!': case '*': case '"': case '\'':
case '(': case ')': case ',':
// hex (prefix only)
case '%':
// reserved (subset)
case '/': case '?': case '=':
// national (subset)
case '~':
return true;
default:
return isalpha(c) || isdigit(c);
}
}
return false;
}
bool
WebLink::DetectUrlWithPrefix(int start)
{
int pos = INT_MAX;
const char* prefix = NULL;
const char* utf8 = fUtf8->String();
// search prefix with smallest position
for (int i = 0; fURLPrefix[i]; i ++) {
int p = fUtf8->FindFirst(fURLPrefix[i], start);
if (p >= start && p < pos) {
pos = p;
prefix = fURLPrefix[i];
}
}
if (pos != INT_MAX) {
fStartPos = pos;
fEndPos = pos + strlen(prefix);
// search end of url
int prev;
int cps;
const char* cp;
prev = fEndPos;
pos = fEndPos;
cp = &utf8[pos];
cps = fWriter->CodePointSize(cp);
while (IsValidCodePoint(cp, cps)) {
prev = pos;
pos += cps;
cp = &utf8[pos];
cps = fWriter->CodePointSize(cp);
}
// skip from end over '.' and '@'
while (fStartPos < prev && (utf8[prev] == '.' || utf8[prev] == '@')) {
// search to begin of code point
do {
prev --;
} while (!fWriter->BeginsChar(utf8[prev]));
}
if (prev != fEndPos) { // url not empty
fEndPos = prev;
return true;
}
}
return false;
}
bool
WebLink::IsValidStart(const char* cp)
{
return *cp != '.' && *cp != '@' && IsValidCodePoint(cp, 1);
}
bool
WebLink::IsValidChar(const char* cp)
{
return IsValidCodePoint(cp, 1);
}
// TODO: add better url detection (ie. "e.g." is detected as "http://e.g")
// A complete implementation should identify these kind of urls correctly:
// domain/~user
// domain/page.html?value=key
bool
WebLink::DetectUrlWithoutPrefix(int start)
{
const char* utf8 = fUtf8->String();
while (utf8[start]) {
// search to start
while (utf8[start] && !IsValidStart(&utf8[start])) {
start += fWriter->CodePointSize(&utf8[start]);
}
// search end and count dots and @s
int numDots = 0, numAts = 0;
int end = start;
int prev = end;
while (utf8[end] && IsValidChar(&utf8[end])) {
if (utf8[end] == '.') numDots ++;
else if (utf8[end] == '@') numAts ++;
prev = end; end += fWriter->CodePointSize(&utf8[end]);
}
// skip from end over '.' and '@'
while (start < prev && (utf8[prev] == '.' || utf8[prev] == '@')) {
if (utf8[prev] == '.') numDots --;
else if (utf8[prev] == '@') numAts --;
// search to begin of code point
do {
prev --;
} while (!fWriter->BeginsChar(utf8[prev]));
}
fStartPos = start; fEndPos = prev;
int32 length = fEndPos - fStartPos;
if (numAts == 1) {
fKind = kMailtoKind;
return true;
} else if (numDots >= 2 && length > 2*numDots+1 && numAts == 0) {
if (strncmp(&utf8[start], "ftp", 3) == 0) fKind = kFtpKind;
else fKind = kHttpKind;
return true;
}
// next iteration
start = end;
}
return false;
}
void
WebLink::DetectLink(int start)
{
fContainsLink = true;
fKind = kUnknownKind;
if (DetectUrlWithPrefix(start)) return;
if (DetectUrlWithoutPrefix(start)) return;
fContainsLink = false;
}
// create link from fStartPos to fEndPos and fStart to end
void
WebLink::CreateLink(float llx, float lly, float urx, float ury)
{
BString url;
// prepend protocol if required
switch (fKind) {
case kMailtoKind: url = "mailto:"; break;
case kHttpKind: url = "http://"; break;
case kFtpKind: url = "ftp://"; break;
case kUnknownKind: break;
default:
LOG((fWriter->fLog, "Error: Link kind missing!!!"));
}
// append url
int endPos = fEndPos + fWriter->CodePointSize(&fUtf8->String()[fEndPos]);
for (int i = fStartPos; i < endPos; i ++) {
url.Append(fUtf8->ByteAt(i), 1);
}
REPORT(kInfo, fWriter->fPage, "Web link '%s'", url.String());
// XXX: url should be in 7-bit ascii encoded!
PDF_add_weblink(fWriter->fPdf, llx, lly, urx, ury, url.String());
}
WebLink::WebLink(PDFWriter* writer, BString* utf8)
: Link(writer, utf8)
{
}
// TextSegment
TextSegment::TextSegment(const char* text, BPoint start, float escpSpace, float escpNoSpace, BRect* bounds, BFont* font, PDFSystem* system)
: fText(text)
, fStart(start)
, fEscpSpace(escpSpace)
, fEscpNoSpace(escpNoSpace)
, fBounds(*bounds)
, fFont(*font)
, fSystem(*system)
, fSpaces(0)
{
}
void TextSegment::PrependSpaces(int32 n) {
ASSERT(fSpaces == 0);
fSpaces = n;
BString spaces;
spaces.Append(' ', n);
fText.Prepend(spaces.String());
}
// TextLine
TextLine::TextLine(PDFWriter* writer)
: fWriter(writer)
{
}
void TextLine::Add(TextSegment* segment) {
// simply skip rotated text
if (segment->Font()->Rotation() != 0.0) {
delete segment; return;
}
if (!Follows(segment)) {
Flush();
}
fSegments.AddItem(segment);
}
bool TextLine::Follows(TextSegment* segment) const {
const int32 n = fSegments.CountItems();
if (n == 0) return true;
TextSegment* s = fSegments.ItemAt(n-1);
// ATM segments must have same PDFSystem!
PDFSystem* os = s->System();
PDFSystem* ns = segment->System();
if (os->Origin() != ns->Origin() || os->Scale() != ns->Scale() || os->Height() != ns->Height()) return false;
// follows the new segment the latest one?
BPoint start = segment->Start();
BRect b = s->Bounds();
float w = segment->Font()->StringWidth(" ", 1);
if (b.top <= start.y && start.y <= b.bottom && (b.right-w/2.0) <= start.x) {
// insert spaces
if (w > 0.0) {
int n = (int)((start.x - b.right) / w);
if (n > 200) n = 200; // santiy check
if (n > 0) {
segment->PrependSpaces(n);
}
}
return true;
}
return false;
}
bool TextLine::BoundingBox(int startPos, int endPos, BRect* bounds) {
const int32 n = fSegments.CountItems();
if (n == 0) return false;
// build the text in the line
BString line;
for (int32 i = 0; i < n; i ++) {
line << fSegments.ItemAt(i)->Text();
}
const char* c = line.String();
const char* pStart = &c[startPos];
const char* pEnd = &c[endPos];
for (int32 i = 0; i < n; i ++) {
TextSegment* seg = fSegments.ItemAt(i);
BPoint pos = seg->Start();
BFont* font = seg->Font();
const char* sc = seg->Text();
float escpSpace = seg->EscpSpace();
float escpNoSpace = seg->EscpNoSpace();
int32 spaces = seg->Spaces();
PDFSystem* system = seg->System();
while (*sc != 0) {
ASSERT(*sc == *c);
int s = fWriter->CodePointSize((char*)c);
float w = font->StringWidth(c, s);
if (c == pStart) {
bounds->left = bounds->right = system->tx(pos.x);
bounds->top = bounds->bottom = system->ty(pos.y);
}
if (pStart <= c && c < pEnd) {
font_height height;
font->GetHeight(&height);
float top = system->ty(pos.y - height.ascent);
float bottom = system->ty(pos.y + height.descent);
if (bounds->top < top) bounds->top = top;
if (bounds->bottom > bottom) bounds->bottom = bottom;
bounds->right = system->tx(pos.x+w);
}
if (spaces == 0) {
// position of next character
if (*(unsigned char*)c <= 0x20) { // should test if c is a white-space!
w += escpSpace;
} else {
w += escpNoSpace;
}
pos.x += w;
} else {
// skip over the prepended spaces
spaces --;
}
// next character
c += s; sc += s;
if (c >= pEnd) {
return true;
}
}
}
return false;
}
void TextLine::Flush() {
const int32 n = fSegments.CountItems();
if (n == 0) return;
// build the text in the line
BString line;
for (int32 i = 0; i < n; i ++) {
line << fSegments.ItemAt(i)->Text();
}
const char* c = line.String();
if (!fWriter->MakesPDF()) {
if (fWriter->fCreateXRefs) fWriter->RecordDests(c);
} else {
// simple link handling for now
WebLink webLink(fWriter, &line);
if (fWriter->fCreateWebLinks) webLink.Do();
// local links
LocalLink localLink(fWriter->fXRefs, fWriter->fXRefDests, fWriter, &line, fWriter->fPage);
if (fWriter->fCreateXRefs) localLink.Do();
// simple bookmark adding
if (fWriter->fCreateBookmarks) {
TextSegment* s = fSegments.ItemAt(0);
BFont* f = s->Font();
PDFSystem* system = s->System();
BPoint start(system->tx(s->Start().x), system->ty(s->Start().y));
font_height height;
f->GetHeight(&height);
float h = system->scale(height.ascent);
fWriter->fBookmark->AddBookmark(start, h, c, f);
}
}
fSegments.MakeEmpty();
}
-135
View File
@@ -1,135 +0,0 @@
/*
Detection and adding of web links.
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _LINK_H
#define _LINK_H
#include <String.h>
#include <Font.h>
#include <Point.h>
#include "PrintUtils.h"
#include "PDFSystem.h"
class PDFSystem;
class PDFWriter;
class TextLine;
class Link {
protected:
PDFWriter* fWriter;
BString* fUtf8;
bool fContainsLink;
int fStartPos, fEndPos;
virtual void DetectLink(int start) = 0;
virtual void CreateLink(float llx, float lly, float urx, float ury) = 0;
void CreateLink();
bool ContainsLink() const { return fContainsLink; }
private:
bool BoundingBox(BRect* rect);
public:
Link(PDFWriter* writer, BString* utf8);
virtual ~Link() {}
void Do();
};
class WebLink : public Link {
enum kind {
kMailtoKind,
kHttpKind,
kFtpKind,
kUnknownKind
};
enum kind fKind;
static const char* fURLPrefix[];
bool IsValidStart(const char* cp);
bool IsValidChar(const char* cp);
bool DetectUrlWithoutPrefix(int start);
bool IsValidCodePoint(const char* cp, int cps);
bool DetectUrlWithPrefix(int start);
void CreateLink(float llx, float lly, float urx, float ury);
void DetectLink(int start);
public:
WebLink(PDFWriter* writer, BString* utf8);
};
class TextSegment {
BString fText;
BPoint fStart;
float fEscpSpace; // escapement space
float fEscpNoSpace; // escapement no space
BRect fBounds;
BFont fFont;
PDFSystem fSystem;
int32 fSpaces;
public:
TextSegment(const char* text, BPoint start, float escpSpace, float escpNoSpace, BRect* bounds, BFont* font, PDFSystem* system);
void PrependSpaces(int32 n);
const char* Text() const { return fText.String(); }
BPoint Start() const { return fStart; }
float EscpSpace() const { return fEscpSpace; }
float EscpNoSpace() const { return fEscpNoSpace; }
BRect Bounds() const { return fBounds; }
BFont* Font() { return &fFont; }
PDFSystem* System() { return &fSystem; }
int32 Spaces() const { return fSpaces; }
};
class TextLine {
TList<TextSegment> fSegments;
PDFWriter* fWriter;
bool Follows(TextSegment* segment) const;
public:
TextLine(PDFWriter* writer);
void Add(TextSegment* segment);
void Flush();
// startPos inclusive, endPos exclusive
bool BoundingBox(int startPos, int endPos, BRect* bounds);
};
#endif
@@ -1,12 +0,0 @@
#ifndef LOG_H
#define LOG_H
#if LOGGING
#define LOG(l) fprintf l
#else
#define LOG(l) ___do_nothing()
inline void ___do_nothing() { }
#endif
#endif
@@ -1,133 +0,0 @@
/*
Mask Cache Item.
Copyright (c) 2003 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <unistd.h>
#include <sys/stat.h>
#include <File.h>
#include "Report.h"
#include "Mask.h"
#include "ImageCache.h"
// Implementation of MaskDescription
MaskDescription::MaskDescription(PDF* pdf, const char* mask, int length, int width, int height, int bpc)
: fPDF(pdf)
, fMask(mask)
, fLength(length)
, fWidth(width)
, fHeight(height)
, fBPC(bpc)
{
}
CacheItem* MaskDescription::NewItem(int id) {
REPORT(kDebug, -1, "MaskDescription::NewItem called");
int imageID;
BString fileName(kMaskPathPrefix);
const char* name;
::Mask* mask = NULL;
fileName << id;
name = fileName.String();
if (!StoreMask(name)) {
REPORT(kError, -1, "Could not store mask in cache.");
return NULL;
}
imageID = MakePDFMask();
if (imageID == -1) {
REPORT(kError, -1, "Could not embed mask in PDF file.");
unlink(name);
} else {
mask = new ::Mask(fPDF, imageID, name, Length(), Width(), Height(), BPC());
}
return mask;
}
bool MaskDescription::StoreMask(const char* name) {
bool ok;
BFile file(name, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
if (file.InitCheck() != B_OK) return false;
ok = file.Write(Mask(), Length()) == Length();
if (!ok) {
unlink(name);
} else {
}
return ok;
}
int MaskDescription::MakePDFMask() {
// *maskId = PDF_open_image(fPdf, "raw", "memory", (const char *) mask, length, width, height, 1, bpc, "mask");
BString options;
int maskID;
PDF_create_pvf(fPDF, "mask", 0, Mask(), Length(), NULL);
options << "width " << fWidth << " height " << fHeight << " components 1 bpc " << fBPC;
maskID = PDF_load_image(fPDF, "raw", "mask", 0, options.String());
PDF_delete_pvf(fPDF, "mask", 0);
return maskID;
}
// Implementation of Mask
Mask::Mask(PDF* pdf, int imageID, const char* fileName, int length, int width, int height, int bpc)
: fPDF(pdf)
, fImageID(imageID)
, fFileName(fileName)
, fLength(length)
, fWidth(width)
, fHeight(height)
, fBPC(bpc)
{
}
Mask::~Mask() {
PDF_close_image(fPDF, ImageID());
unlink(FileName());
}
bool Mask::Equals(CIDescription* description) const {
REPORT(kDebug, -1, "Mask::Equals called");
MaskDescription* desc = dynamic_cast<MaskDescription*>(description);
if (desc && Length() == desc->Length() && Width() == desc->Width() && Height() == desc->Height() && BPC() == desc->BPC()) {
off_t size;
BFile file(FileName(), B_READ_ONLY);
if (file.InitCheck() == B_OK && file.GetSize(&size) == B_OK && size == Length()) {
char* buffer = new char[Length()];
if (buffer == NULL) return false;
bool ok = file.Read(buffer, Length()) == Length() &&
memcmp(desc->Mask(), buffer, Length()) == 0;
delete[] buffer;
return ok;
}
}
return false;
}
@@ -1,85 +0,0 @@
/*
Mask Cache Item.
Copyright (c) 2003 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _MASK_CACHE_ITEM_H
#define _MASK_CACHE_ITEM_H
#include <String.h>
#include "pdflib.h"
#include "Cache.h"
class MaskDescription : public CIDescription {
public:
MaskDescription(PDF* pdf, const char* mask, int length, int width, int height, int bpc);
CacheItem* NewItem(int id);
const char* Mask() const { return fMask; }
int Length() const { return fLength; }
int Width() const { return fWidth; }
int Height() const { return fHeight; }
int BPC() const { return fBPC; }
private:
bool StoreMask(const char* name);
int MakePDFMask();
PDF* fPDF;
const char* fMask;
int fLength;
int fWidth;
int fHeight;
int fBPC;
};
class Mask : public CacheItem {
public:
Mask(PDF* pdf, int imageID, const char* fileName, int length, int width, int height, int bpc);
~Mask();
int ImageID() const { return fImageID; };
const char* FileName() const { return fFileName.String(); };
int Length() const { return fLength; };
int Width() const { return fWidth; }
int Height() const { return fHeight; }
int BPC() const { return fBPC; }
bool Equals(CIDescription* desc) const;
private:
PDF* fPDF;
int fImageID;
BString fFileName;
int fLength;
int fWidth;
int fHeight;
int fBPC;
};
#endif
@@ -1,183 +0,0 @@
/*
MessagePrinter.cpp
Copyright (c) 2001 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <SupportKit.h>
#include <Alert.h>
#include "MessagePrinter.h"
/**
* Print()
*
* @param BMessage*
* @return status_t, any result from the operation
*/
status_t MessagePrinter::Print(BMessage* msg)
{
status_t status;
BFile file;
BPath settingsPath;
// char settingsPath[B_PATH_NAME_LENGTH];
char *name;
uint32 type;
int32 count;
// open a file to print message on the desktop
status = find_directory(B_DESKTOP_DIRECTORY, &settingsPath);
if (status != B_OK) {
BAlert* alert = new BAlert("","Find directory error", "Doh!");
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
return status;
}
settingsPath.Append(msgFileName);
status = file.SetTo(settingsPath.Path(), B_WRITE_ONLY | B_CREATE_FILE);
if (status != B_OK) {
BAlert* alert = new BAlert("","File write error", "Doh!");
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
return status;
}
// print the contents of the message to file
for ( int32 i = 0;
msg->GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK;
i++ )
{
BString out;
// count
out << i;
if (file.Write(out.String(), out.Length()) < 0) {
BAlert* alert = new BAlert("","Count write error", "Doh!");
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
return B_ERROR;
}
// name
out = " ";
out << name;
if (file.Write(out.String(), out.Length()) < 0) {
BAlert* alert = new BAlert("","Name write error", "Doh!");
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
return B_ERROR;
}
// type
switch (type) {
case B_INT32_TYPE:
{
int32 v;
out = " B_INT32_TYPE ";
msg->FindInt32(name, 0, &v);
out << v << '\n';
}
break;
case B_UINT32_TYPE:
{
int32 v;
out = " B_UINT32_TYPE ";
msg->FindInt32(name, 0, &v);
out << v << '\n';
}
break;
case B_INT64_TYPE:
{
int64 v;
out = " B_INT64_TYPE ";
msg->FindInt64(name, 0, &v);
out << v << '\n';
}
break;
case B_FLOAT_TYPE:
{
float f;
out = " B_FLOAT_TYPE ";
msg->FindFloat(name, 0, &f);
out << f << '\n';
}
break;
case B_BOOL_TYPE:
{
bool b;
out = " B_BOOL_TYPE ";
msg->FindBool(name, 0, &b);
out << (int)b << '\n';
}
break;
case B_MESSAGE_TYPE:
{
BMessage *m = new BMessage();
MessagePrinter *mp = new MessagePrinter(name);
msg->FindMessage(name, m);
mp->Print(m);
out = " B_MESSAGE_TYPE \n";
delete m;
delete mp;
}
break;
case B_RECT_TYPE:
{
BRect r;
out = " B_RECT_TYPE ";
msg->FindRect(name, 0, &r);
out << "{ "
<< r.left <<" "
<< r.top <<" "
<< r.right <<" "
<< r.bottom <<" "
<< " }"
<< '\n';
}
break;
case B_STRING_TYPE:
{
BString s;
out = " B_STRING_TYPE ";
msg->FindString(name, 0, &s);
out << s.String() << '\n';
}
break;
default:
out = " UNKNOWN TYPE \n";
break;
}
if (file.Write(out.String(), out.Length()) < 0) {
BAlert* alert = new BAlert("","Value write error", "Doh!");
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
return B_ERROR;
}
}
return status;
}
@@ -1,59 +0,0 @@
/*
MessagePrinter.h
Copyright (c) 2001 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef MSG_PRINTER_H
#define MSG_PRINTER_H
#include <StorageKit.h>
#include <SupportKit.h>
#include <string.h>
const char FILE_NAME[] = "MessageFile";
/**
* Class
*/
class MessagePrinter
{
private:
BNode node;
status_t _err;
char msgFileName[B_FILE_NAME_LENGTH];
public:
MessagePrinter() { strcpy(msgFileName, FILE_NAME); }
MessagePrinter(const char *fileName) { strcpy(msgFileName, fileName); }
~MessagePrinter() { }
status_t Print(BMessage *msg);
};
#endif
@@ -1,59 +0,0 @@
Notes:
1) Called after printer is created:
char* add_printer(char* printer_name);
2) Called by print_server if app uses page setup settings before calling
ConfigPage().
BMessage* default_settings(BNode* printer);
BNode is the spool dir where attributes exist
BMessage contains the attribute default settings
3) Called by BPrintJob::ConfigPage()
BMessage* config_page(BNode* printer, BMessage* settings);
BMessage* settings is the current settings
returns the settings specified in the dialog
4) Called by print_server to start printing
BMessage* take_job(BFile* spool, BNode* printer, BMessage* msg);
- there is always a config_page() before a config_job()
- if settings passed to config_job is empty the print_server will call
config_page()
Path for settings:
1) default_settings() should write the attributes to the BNode and return
them in the BMessage
2) config_page() could be called with an empty settings BMessage, which
should then call default_settings()?
- default_settings does not exist
=====================================================
Simon 02/01/2002:
=====================================================
1) Added default_settings() to Driver.cpp to use PrinterSettings class that controls settings
- accorting to the scheme above I have found no code that calls page setup before calling ConfigPage(), so the default_settings() function never gets called resulting in a badly formated message (has the wrong set of data fields we need) being sent to PageSetupWindow constructor. Therefore, on the council of Philippe, I have added a Validate() method to the PrinterSettings class that validates the structure of the message and adds constructs the message to be correct for PageSetupWindow. This means that PageSetupWindow will always get a good message, and I have taken out the code in the PageSetupWindow constructor to check for the presence of the data fields it needs. However, the result of the initial problem, that default_settings() is not called, resulted in my adding these Validate calls to both config_page() and config_job() functions, which really they should not be there...
- what is really needed is a test app with a bunch of test harnesses to check all combination of app based printing scenarios, and also test for bad coding errors that an app may perform, rather than using StyleEdit and Gobe to test the driver.
NOTE: depending on the app that causes config_page() to be called, the message will have different configurations of data fields. StyledEdit passes only a single field, while Gobe passes a bunch. The issue is that config_page() cannot simply call default_settings() in the case where the message does not have the data fields we want, since we will wipe them out with the new default one. So rather than calling default_settings() from config_page(), I just add the data fields we need with a call to PrinterSettings::ReadSettings(), or PrinterSettings::GetDefaults() if there are no previously saved settings.
2) Code now does the following:
a) Reads BNode to check if there is a previous BFS attibute called printer_settings that has the latest default settings
b) If no attib printer_settings, then reads pdf_default_settings file in /home/config/settings for initial defaults. If pdf_default_settings not there, it uses hard coded values, writes the pdf_default_settings file and saves BMessage to spool BNode as a BFS attribute called printer_settings
c) If pdf_default_settings are there it uses these values, then saves BMessage to spool BNode as a BFS attribute called printer_settings
d) PageSetupWindow::UpdateSetupMessage() will call the PrinterSettings class to write the new settings created in the dialog to the spooler BNode attribute printer_settings
3) Added a debug MessagePrinter class that prints the contents of a BMessage to a text file on the desktop with the name of the message as the name of the file. If there are BMessages in the BMessage it will print these too, but in seperate files. You can see the use of this class in the code commented out in Driver.cpp, which should be removed at some later time, and perhaps put in a printer testing app.
@@ -1,65 +0,0 @@
/*
PDFLinePathBuilder
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "PDFLinePathBuilder.h"
PDFLinePathBuilder::PDFLinePathBuilder(SubPath *subPath, PDFWriter *writer)
: LinePathBuilder(subPath, writer->PenSize(), writer->LineCapMode(), writer->LineJoinMode(), writer->LineMiterLimit())
, fWriter(writer)
{
}
void
PDFLinePathBuilder::MoveTo(BPoint p)
{
PDF_moveto(Pdf(), tx(p.x), ty(p.y));
}
void
PDFLinePathBuilder::LineTo(BPoint p)
{
PDF_lineto(Pdf(), tx(p.x), ty(p.y));
}
void
PDFLinePathBuilder::BezierTo(BPoint p[3])
{
PDF_curveto(Pdf(),
tx(p[0].x), ty(p[0].y),
tx(p[1].x), ty(p[1].y),
tx(p[2].x), ty(p[2].y));
}
void
PDFLinePathBuilder::ClosePath(void)
{
PDF_closepath(Pdf());
}
@@ -1,54 +0,0 @@
/*
PDFLinePathBuilder
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef PDFLINE_PATH_BUILDER_H
#define PDFLINE_PATH_BUILDER_H
#include "LinePathBuilder.h"
#include "PDFWriter.h"
class PDFLinePathBuilder : public LinePathBuilder
{
PDFWriter *fWriter;
PDF *Pdf() const { return fWriter->fPdf; }
float tx(float x) const { return fWriter->tx(x); }
float ty(float y) const { return fWriter->ty(y); }
protected:
void MoveTo(BPoint p);
void LineTo(BPoint p);
void BezierTo(BPoint p[3]);
void ClosePath(void);
public:
PDFLinePathBuilder(SubPath *subPath, PDFWriter *writer);
};
#endif
@@ -1,63 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001-2003 OpenBeOS.
Copyright (c) 2006 Haiku.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _PDF_SYSTEM_H
#define _PDF_SYSTEM_H
// PDF coordinate system
class PDFSystem {
private:
float fHeight;
float fX;
float fY;
float fScale;
public:
PDFSystem()
: fHeight(0), fX(0), fY(0), fScale(1) { }
PDFSystem(float h, float x, float y, float s)
: fHeight(h), fX(x), fY(y), fScale(s) { }
void SetHeight(float h) { fHeight = h; }
void SetOrigin(float x, float y) { fX = x; fY = y; }
void SetScale(float scale) { fScale = scale; }
float Height() const { return fHeight; }
BPoint Origin() const { return BPoint(fX, fY); }
float Scale() const { return fScale; }
inline float tx(float x) { return fX + fScale*x; }
inline float ty(float y) { return fHeight - (fY + fScale * y); }
inline float scale(float f) { return fScale * f; }
};
#endif
@@ -1,614 +0,0 @@
/*
* Copyright 2001-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Philippe Houdoin
* Simon Gauvin
* Michael Pfeiffer
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <Debug.h>
#include <StorageKit.h>
#include <TranslationKit.h>
#include <support/UTF8.h>
#include "PDFWriter.h"
#include "Link.h"
#include "Bookmark.h"
#include "DrawShape.h"
#include "XReferences.h"
#include "Log.h"
#include "Report.h"
#include "pdflib.h"
typedef struct {
uint16 from;
uint16 to;
int16 length;
uint16 *unicodes;
} unicode_to_encoding;
typedef struct {
uint16 unicode;
uint16 cid;
} unicode_to_cid;
typedef struct {
uint16 length;
unicode_to_cid *table;
} cid_table;
#ifdef UNICODE5_FROM
# error check code!
#endif
#define ELEMS(v, e) sizeof(v) / sizeof(e)
// Adobe Glyph List
#include "enc_range.h"
#include "unicode0.h"
#include "unicode1.h"
#include "unicode2.h"
#include "unicode3.h"
#include "unicode4.h"
static unicode_to_encoding encodings[] = {
{UNICODE0_FROM, UNICODE0_TO, ELEMS(unicode0, uint16), unicode0},
{UNICODE1_FROM, UNICODE1_TO, ELEMS(unicode1, uint16), unicode1},
{UNICODE2_FROM, UNICODE2_TO, ELEMS(unicode2, uint16), unicode2},
{UNICODE3_FROM, UNICODE3_TO, ELEMS(unicode3, uint16), unicode3},
{UNICODE4_FROM, UNICODE4_TO, ELEMS(unicode4, uint16), unicode4}
};
// unicode to cid
#include "japanese.h"
#include "gb1.h"
#include "cns1.h"
#include "korean.h"
static cid_table cid_tables[] = {
{ELEMS(japanese, unicode_to_cid), japanese},
{ELEMS(CNS1, unicode_to_cid), CNS1},
{ELEMS(GB1, unicode_to_cid), GB1},
{ELEMS(korean, unicode_to_cid), korean}
};
static const char* encoding_names[] = {
"macroman",
// TrueType
"ttenc0",
"ttenc1",
"ttenc2",
"ttenc3",
"ttenc4",
// Type 1
"t1enc0",
"t1enc1",
"t1enc2",
"t1enc3",
"t1enc4",
// CJK
"UniJIS-UCS2-H",
"UniCNS-UCS2-H",
"UniGB-UCS2-H",
"UniKS-UCS2-H"
};
// #pragma mark -
static bool
find_encoding(uint16 unicode, uint8 &encoding, uint16 &index)
{
for (unsigned int i = 0; i < ELEMS(encodings, unicode_to_encoding); i++) {
if (encodings[i].from <= unicode && unicode <= encodings[i].to) {
int16 bottom = 0;
int16 top = encodings[i].length-1;
uint16* codes = encodings[i].unicodes;
while (top >= bottom) {
int16 m = (top + bottom) / 2;
if (unicode < codes[m]) {
top = m-1;
} else if (unicode > codes[m]) {
bottom = m+1;
} else {
index = m;
encoding = i;
return true;
}
}
return false;
}
}
return false;
}
static bool
find_in_cid_tables(uint16 unicode, font_encoding &encoding, uint16 &index,
font_encoding* order)
{
for (unsigned int i = 0; i < ELEMS(cid_tables, cid_table); i++) {
encoding = order[i];
if (encoding == invalid_encoding) break;
int index = encoding - first_cjk_encoding;
int32 bottom = 0;
int32 top = cid_tables[index].length-1;
unicode_to_cid *table = cid_tables[index].table;
while (top >= bottom) {
int32 m = (top + bottom) / 2;
if (unicode < table[m].unicode) {
top = m-1;
} else if (unicode > table[m].unicode) {
bottom = m+1;
} else {
index = table[m].cid;
return true;
}
}
}
return false;
}
void
PDFWriter::MakeUserDefinedEncoding(uint16 unicode, uint8 &enc, uint8 &index)
{
if (fUserDefinedEncodings.Get(unicode, enc, index)) {
BString s("user");
s << (int)enc;
PDF_encoding_set_char(fPdf, s.String(), (int)index, NULL, (int)unicode);
}
}
void
PDFWriter::RecordFont(const char* family, const char* style, float size)
{
const int32 n = fUsedFonts.CountItems();
for (int32 i = 0; i < n; i ++) {
if (fUsedFonts.ItemAt(i)->Equals(family, style, size)) return;
}
UsedFont* font;
font = new UsedFont(family, style, size);
fUsedFonts.AddItem(font);
REPORT(kInfo, -1, "Used font: \"%s\" \"%s\" %f", family, style, size);
}
void
PDFWriter::GetFontName(BFont *font, char *fontname)
{
font_family family;
font_style style;
font->GetFamilyAndStyle(&family, &style);
strcat(strcat(strcpy(fontname, family), "-"), style);
RecordFont(family, style, font->Size());
}
void
PDFWriter::GetFontName(BFont *font, char *fontname, bool &embed,
font_encoding encoding)
{
GetFontName(font, fontname);
switch (encoding) {
case japanese_encoding:
strcpy(fontname, "HeiseiMin-W3"); return;
case chinese_cns1_encoding:
strcpy(fontname, "MHei-Medium"); return;
case chinese_gb1_encoding:
strcpy(fontname, "STSong-Light"); return;
case korean_encoding:
strcpy(fontname, "HYGoThic-Medium"); return;
default:;
}
}
int
PDFWriter::FindFont(char* fontName, bool embed, font_encoding encoding)
{
static Font* cache = NULL;
if (cache && cache->encoding == encoding
&& strcmp(cache->name.String(), fontName) == 0)
return cache->font;
REPORT(kDebug, fPage, "FindFont %s", fontName);
Font *f = NULL;
const int n = fFontCache.CountItems();
for (int i = 0; i < n; i++) {
f = fFontCache.ItemAt(i);
if (f->encoding == encoding && strcmp(f->name.String(), fontName) == 0) {
cache = f;
return f->font;
}
}
if (embed) embed = EmbedFont(fontName);
BString s;
const char* encoding_name;
if (encoding < user_defined_encoding_start) {
encoding_name = encoding_names[encoding];
} else {
s = "user";
s << (int)(encoding - user_defined_encoding_start);
encoding_name = s.String();
}
REPORT(kDebug, fPage, "Create new font, %sembed, encoding %s",
embed ? "" : "do not ", encoding_name);
int font = PDF_findfont(fPdf, fontName, encoding_name, embed);
if (font != -1) {
REPORT(kDebug, fPage, "font created");
cache = new Font(fontName, font, encoding);
fFontCache.AddItem(cache);
} else {
REPORT(kError, fPage, "Could not create font '%s': %s", fontName,
PDF_get_errmsg(fPdf));
}
return font;
}
void
PDFWriter::ToUtf8(uint32 encoding, const char *string, BString &utf8)
{
int32 len = strlen(string);
int32 srcLen = len, destLen = 255;
int32 state = 0;
char buffer[256];
int32 srcStart = 0;
do {
convert_to_utf8(encoding, &string[srcStart], &srcLen, buffer, &destLen,
&state);
srcStart += srcLen;
len -= srcLen;
srcLen = len;
utf8.Append(buffer, destLen);
destLen = 255;
} while (len > 0);
};
void
PDFWriter::ToUnicode(const char *string, BString &unicode)
{
int32 len = strlen(string);
int32 srcLen = len, destLen = 255;
int32 state = 0;
char buffer[256];
int32 srcStart = 0;
int i = 0;
unicode = "";
if (len == 0) return;
do {
convert_from_utf8(B_UNICODE_CONVERSION, &string[srcStart], &srcLen,
buffer, &destLen, &state);
srcStart += srcLen;
len -= srcLen;
srcLen = len;
char *b = unicode.LockBuffer(i + destLen);
memcpy(&b[i], buffer, destLen);
unicode.UnlockBuffer(i + destLen);
i += destLen;
destLen = 255;
} while (len > 0);
}
void
PDFWriter::ToPDFUnicode(const char *string, BString &unicode)
{
// PDFlib requires BOM at begin and two 0 at end of string
BString s;
ToUnicode(string, s);
unicode << "\xfe\xff";
int32 len = s.Length()+2;
char* buf = unicode.LockBuffer(len + 2);
// reserve space for two additional '\0'
memcpy(&buf[2], s.String(), s.Length());
buf[len] = buf[len+1] = 0;
unicode.UnlockBuffer(len + 2);
}
uint16
PDFWriter::CodePointSize(const char* s)
{
uint16 i = 1;
for (s++; !BeginsChar(*s); s++) i++;
return i;
}
void
PDFWriter::RecordDests(const char* s)
{
::RecordDests record(fXRefDests, &fTextLine, fPage);
fXRefs->Matches(s, &record, true);
}
void
PDFWriter::DrawChar(uint16 unicode, const char* utf8, int16 size)
{
// try to convert from utf8 to MacRoman encoding schema...
int32 srcLen = size;
int32 destLen = 1;
char dest[3] = "\0\0";
int32 state = 0;
bool embed = true;
font_encoding encoding = macroman_encoding;
char fontName[B_FONT_FAMILY_LENGTH+B_FONT_STYLE_LENGTH+1];
if (convert_from_utf8(B_MAC_ROMAN_CONVERSION, utf8, &srcLen, dest, &destLen,
&state, 0) != B_OK || dest[0] == 0) {
// could not convert to MacRoman
font_encoding fenc;
uint16 index = 0;
uint8 enc;
GetFontName(&fState->beFont, fontName);
embed = EmbedFont(fontName);
REPORT(kDebug, -1, "find_encoding unicode %d\n", (int)unicode);
if (find_encoding(unicode, enc, index)) {
// is code point in the Adobe Glyph List?
// Note if rendering the glyphs only would be desired, we could
// always use the second method below (MakeUserDefinedEncoding),
// but extracting text from the generated PDF would be almost
// impossible (OCR!)
REPORT(kDebug, -1, "encoding for %x -> %d %d", unicode, (int)enc,
(int)index);
// use one of the user pre-defined encodings
if (fState->beFont.FileFormat() == B_TRUETYPE_WINDOWS) {
encoding = font_encoding(enc + tt_encoding0);
} else {
encoding = font_encoding(enc + t1_encoding0);
}
*dest = index;
} else if (embed) {
// if the font is embedded, create a user defined encoding at runtime
uint8 index;
MakeUserDefinedEncoding(unicode, enc, index);
*dest = index;
encoding = font_encoding(user_defined_encoding_start + enc);
} else if (find_in_cid_tables(unicode, fenc, index, fFontSearchOrder)) {
// font is not embedded use one of the CJK fonts for substitution
REPORT(kDebug, -1, "cid table %d index = %d", (int)fenc, (int)index);
dest[0] = unicode / 256;
dest[1] = unicode % 256;
destLen = 2;
encoding = fenc;
embed = false;
} else {
static bool found = false;
REPORT(kDebug, -1, "encoding for %x not found!", (int)unicode);
if (!found) {
found = true;
REPORT(kError, fPage, "Could not find an encoding for character "
"with unicode %d! Message is not repeated for other unicode "
"values.", (int)unicode);
}
*dest = 0; // paint a box (is 0 a box in MacRoman) or
return; // simply skip character
}
} else {
REPORT(kDebug, -1, "macroman srcLen=%d destLen=%d dest= %d %d!", srcLen,
destLen, (int)dest[0], (int)dest[1]);
}
// Note we have to build the user defined encoding before it is used in
// PDF_find_font!
if (!MakesPDF()) return;
int font;
GetFontName(&fState->beFont, fontName, embed, encoding);
font = FindFont(fontName, embed, encoding);
if (font < 0) {
REPORT(kWarning, fPage, "**** PDF_findfont(%s) failed, back to default "
"font", fontName);
font = PDF_findfont(fPdf, "Helvetica", "macroman", 0);
}
fState->font = font;
uint16 face = fState->beFont.Face();
PDF_set_parameter(fPdf, "underline", (face & B_UNDERSCORE_FACE) != 0
? "true" : "false");
PDF_set_parameter(fPdf, "strikeout", (face & B_STRIKEOUT_FACE) != 0
? "true" : "false");
PDF_set_value(fPdf, "textrendering", (face & B_OUTLINED_FACE) != 0 ? 1 : 0);
PDF_setfont(fPdf, fState->font, scale(fState->beFont.Size()));
const float x = tx(fState->penX);
const float y = ty(fState->penY);
const float rotation = fState->beFont.Rotation();
const bool rotate = rotation != 0.0;
if (rotate) {
PDF_save(fPdf);
PDF_translate(fPdf, x, y);
PDF_rotate(fPdf, rotation);
PDF_set_text_pos(fPdf, 0, 0);
} else
PDF_set_text_pos(fPdf, x, y);
PDF_show2(fPdf, dest, destLen);
if (rotate) {
PDF_restore(fPdf);
}
}
void
PDFWriter::ClipChar(BFont* font, const char* unicode, const char* utf8,
int16 size, float width)
{
BShape glyph;
bool hasGlyph[1];
font->GetHasGlyphs(utf8, 1, hasGlyph);
if (hasGlyph[0]) {
BShape *glyphs[1];
glyphs[0] = &glyph;
font->GetGlyphShapes(utf8, 1, glyphs);
} else {
REPORT(kWarning, fPage, "glyph for %*.*s not found!", size, size, utf8);
// create a rectangle instead
font_height height;
fState->beFont.GetHeight(&height);
BRect r(0, 0, width, height.ascent);
float w = r.Width() < r.Height() ? r.Width()*0.1 : r.Height()*0.1;
BRect o = r; o.InsetBy(w, w);
w *= 2.0;
BRect i = r; i.InsetBy(w, w);
o.OffsetBy(0, -height.ascent);
i.OffsetBy(0, -height.ascent);
glyph.MoveTo(BPoint(o.left, o.top));
glyph.LineTo(BPoint(o.right, o.top));
glyph.LineTo(BPoint(o.right, o.bottom));
glyph.LineTo(BPoint(o.left, o.bottom));
glyph.Close();
glyph.MoveTo(BPoint(i.left, i.top));
glyph.LineTo(BPoint(i.left, i.bottom));
glyph.LineTo(BPoint(i.right, i.bottom));
glyph.LineTo(BPoint(i.right, i.top));
glyph.Close();
}
BPoint p(fState->penX, fState->penY);
PushInternalState(); SetOrigin(p);
{
DrawShape iterator(this, false);
iterator.Iterate(&glyph);
}
PopInternalState();
}
void
PDFWriter::DrawString(char *string, float escapementNoSpace,
float escapementSpace)
{
REPORT(kDebug, fPage, "DrawString string=\"%s\", escapementNoSpace=%f, "
"escapementSpace=%f, at %f, %f", string, escapementNoSpace,
escapementSpace, fState->penX, fState->penY);
if (IsDrawing()) {
// text color is always the high color and not the pattern!
SetColor(fState->foregroundColor);
}
// convert string to UTF8
BString utf8;
if (fState->beFont.Encoding() == B_UNICODE_UTF8) {
utf8 = string;
} else {
ToUtf8(fState->beFont.Encoding()-1, string, utf8);
}
// convert string in UTF8 to unicode UCS2
BString unicode;
ToUnicode(utf8.String(), unicode);
// need font object to calculate width of utf8 code point
BFont font = fState->beFont;
font.SetEncoding(B_UNICODE_UTF8);
// constants to calculate position of next character
const double rotation = DEGREE2RAD(fState->beFont.Rotation());
const bool rotate = rotation != 0.0;
const double cos1 = rotate ? cos(rotation) : 1;
const double sin1 = rotate ? -sin(rotation) : 0;
BPoint start(fState->penX, fState->penY);
BeginTransparency();
// If !MakesPDF() all the effort below just for the bounding box!
// draw each character
const char *c = utf8.String();
const unsigned char *u = (unsigned char*)unicode.String();
for (int i = 0; i < unicode.Length(); i += 2) {
int s = CodePointSize((char*)c);
float w = font.StringWidth(c, s);
if (MakesPDF() && IsClipping()) {
ClipChar(&font, (char*)u, c, s, w);
} else {
DrawChar(u[0]*256+u[1], c, s);
}
// position of next character
if (*(unsigned char*)c <= 0x20) { // should test if c is a white-space!
w += escapementSpace;
} else {
w += escapementNoSpace;
}
fState->penX += w * cos1;
fState->penY += w * sin1;
// next character
c += s; u += 2;
}
EndTransparency();
// text line processing (for non rotated text only!)
BPoint end(fState->penX, fState->penY);
BRect bounds;
font_height height;
font.GetHeight(&height);
bounds.left = start.x;
bounds.right = end.x;
bounds.top = start.y - height.ascent;
bounds.bottom = end.y + height.descent;
TextSegment* segment = new TextSegment(utf8.String(), start, escapementSpace,
escapementNoSpace, &bounds, &font, pdfSystem());
fTextLine.Add(segment);
}
bool
PDFWriter::EmbedFont(const char* name)
{
static FontFile* cache = NULL;
if (cache && strcmp(cache->Name(), name) == 0) return cache->Embed();
const int n = fFonts->Length();
for (int i = 0; i < n; i++) {
FontFile* f = fFonts->At(i);
if (strcmp(f->Name(), name) == 0) {
cache = f;
return f->Embed();
}
}
return false;
}
File diff suppressed because it is too large Load Diff
@@ -1,398 +0,0 @@
/*
* Copyright 2001-2009, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Philippe Houdoin
* Simon Gauvin
* Michael Pfeiffer
*/
#ifndef PDFWRITER_H
#define PDFWRITER_H
#include <AppKit.h>
#include <InterfaceKit.h>
#include <String.h>
#include <List.h>
#include <math.h>
#include "PrinterDriver.h"
#include "PictureIterator.h"
#include "Fonts.h"
#include "SubPath.h"
#include "PrintUtils.h"
#include "Link.h"
#include "ImageCache.h"
#include "PDFSystem.h"
#include "pdflib.h"
#define USE_IMAGE_CACHE 1
#define RAD2DEGREE(r) (180.0 * r / M_PI)
#define DEGREE2RAD(d) (M_PI * d / 180.0)
class DrawShape;
class WebLink;
class Bookmark;
class XRefDefs;
class XRefDests;
class PDFWriter : public PrinterDriver, public PictureIterator {
friend class DrawShape;
friend class PDFLinePathBuilder;
friend class WebLink;
friend class Link;
friend class Bookmark;
friend class LocalLink;
friend class TextLine;
public:
// constructors / destructor
PDFWriter();
~PDFWriter();
// public methods
status_t BeginJob();
status_t PrintPage(int32 pageNumber, int32 pageCount);
status_t EndJob();
status_t InitWriter();
status_t BeginPage(BRect paperRect, BRect printRect);
status_t EndPage();
void SetAttribute(const char* name, const char* value);
bool LoadBookmarkDefinitions(const char* name);
bool LoadXRefsDefinitions(const char* name);
void RecordDests(const char* s);
// PDFLib callbacks
size_t WriteData(void *data, size_t size);
void ErrorHandler(int type, const char *msg);
// Image support
int32 BytesPerPixel(int32 pixelFormat);
bool HasAlphaChannel(int32 pixelFormat);
bool NeedsBPC1Mask(int32 pixelFormat);
inline bool IsTransparentRGB32(uint8* in);
inline bool IsTransparentRGBA32(uint8* in);
inline bool IsTransparentRGB32_BIG(uint8* in);
inline bool IsTransparentRGBA32_BIG(uint8* in);
//inline bool IsTransparentRGB24(uint8* in);
//inline bool IsTransparentRGB24_BIG(uint8* in);
//inline bool IsTransparentRGB16(uint8* in);
//inline bool IsTransparentRGB16_BIG(uint8* in);
inline bool IsTransparentRGB15(uint8* in);
inline bool IsTransparentRGB15_BIG(uint8* in);
inline bool IsTransparentRGBA15(uint8* in);
inline bool IsTransparentRGBA15_BIG(uint8* in);
inline bool IsTransparentCMAP8(uint8* in);
//inline bool IsTransparentGRAY8(uint8* in);
//inline bool IsTransparentGRAY1(uint8* in);
inline uint8 AlphaFromRGBA32(uint8* in);
inline uint8 AlphaFromRGBA32_BIG(uint8* in);
inline void ConvertFromRGB32(uint8* in, uint8* out);
inline void ConvertFromRGB32_BIG(uint8* in, uint8* out);
inline void ConvertFromRGBA32(uint8* in, uint8* out);
inline void ConvertFromRGBA32_BIG(uint8* in, uint8* out);
inline void ConvertFromRGB24(uint8* in, uint8* out);
inline void ConvertFromRGB24_BIG(uint8* in, uint8* out);
inline void ConvertFromRGB16(uint8* in, uint8* out);
inline void ConvertFromRGB16_BIG(uint8* in, uint8* out);
inline void ConvertFromRGB15(uint8* in, uint8* out);
inline void ConvertFromRGBA15_BIG(uint8* in, uint8* out);
inline void ConvertFromRGB15_BIG(uint8* in, uint8* out);
inline void ConvertFromRGBA15(uint8* in, uint8* out);
inline void ConvertFromCMAP8(uint8* in, uint8* out);
inline void ConvertFromGRAY8(uint8* in, uint8* out);
inline void ConvertFromGRAY1(uint8* in, uint8* out, int8 bit);
uint8 *CreateMask(BRect src, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data);
uint8 *CreateSoftMask(BRect src, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data);
BBitmap *ConvertBitmap(BRect src, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data);
bool GetImages(BRect src, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data, int* mask, int* image);
// String handling
bool BeginsChar(char byte) { return BEGINS_CHAR(byte); }
void ToUtf8(uint32 encoding, const char *string, BString &utf8);
void ToUnicode(const char *string, BString &unicode);
void ToPDFUnicode(const char *string, BString &unicode);
uint16 CodePointSize(const char *s);
void DrawChar(uint16 unicode, const char *utf8, int16 size);
void ClipChar(BFont* font, const char* unicode, const char *utf8, int16 size, float width);
bool EmbedFont(const char* n);
void DeclareEncodingFiles();
void DeclareEncodingFile(BPath* path, const char* id,
const char* name);
status_t DeclareFonts();
void RecordFont(const char* family, const char* style, float size);
// BPicture playback handlers
void Op(int number);
void MovePenBy(BPoint delta);
void StrokeLine(BPoint start, BPoint end);
void StrokeRect(BRect rect);
void FillRect(BRect rect);
void StrokeRoundRect(BRect rect, BPoint radii);
void FillRoundRect(BRect rect, BPoint radii);
void StrokeBezier(BPoint *control);
void FillBezier(BPoint *control);
void StrokeArc(BPoint center, BPoint radii, float startTheta, float arcTheta);
void FillArc(BPoint center, BPoint radii, float startTheta, float arcTheta);
void StrokeEllipse(BPoint center, BPoint radii);
void FillEllipse(BPoint center, BPoint radii);
void StrokePolygon(int32 numPoints, BPoint *points, bool isClosed);
void FillPolygon(int32 numPoints, BPoint *points, bool isClosed);
void StrokeShape(BShape *shape);
void FillShape(BShape *shape);
void DrawString(char *string, float deltax, float deltay);
void DrawPixels(BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data);
void SetClippingRects(BRect *rects, uint32 numRects);
void ClipToPicture(BPicture *picture, BPoint point, bool clip_to_inverse_picture);
void PushState();
void PopState();
void EnterStateChange();
void ExitStateChange();
void EnterFontState();
void ExitFontState();
void SetOrigin(BPoint pt);
void SetPenLocation(BPoint pt);
void SetDrawingMode(drawing_mode mode);
void SetLineMode(cap_mode capMode, join_mode joinMode, float miterLimit);
void SetPenSize(float size);
void SetForeColor(rgb_color color);
void SetBackColor(rgb_color color);
void SetStipplePattern(pattern p);
void SetScale(float scale);
void SetFontFamily(char *family);
void SetFontStyle(char *style);
void SetFontSpacing(int32 spacing);
void SetFontSize(float size);
void SetFontRotate(float rotation);
void SetFontEncoding(int32 encoding);
void SetFontFlags(int32 flags);
void SetFontShear(float shear);
void SetFontFace(int32 flags);
static inline bool IsSame(const pattern &p1, const pattern &p2);
static inline bool IsSame(const rgb_color &c1, const rgb_color &c2);
private:
enum PDFVersion {
kPDF13,
kPDF14,
kPDF15
};
class State
{
public:
State *prev;
BFont beFont;
int font;
PDFSystem pdfSystem;
float penX;
float penY;
drawing_mode drawingMode;
rgb_color foregroundColor;
rgb_color backgroundColor;
rgb_color currentColor;
cap_mode capMode;
join_mode joinMode;
float miterLimit;
float penSize;
pattern pattern0;
int32 fontSpacing;
// initialize with defalt values
State(float h = a4_height, float x = 0, float y = 0)
{
static rgb_color white = {255, 255, 255, 255};
static rgb_color black = {0, 0, 0, 255};
prev = NULL;
font = 0;
pdfSystem.SetHeight(h);
pdfSystem.SetOrigin(x, y);
penX = 0;
penY = 0;
drawingMode = B_OP_COPY;
foregroundColor = white;
backgroundColor = black;
currentColor = black;
capMode = B_BUTT_CAP;
joinMode = B_MITER_JOIN;
miterLimit = B_DEFAULT_MITER_LIMIT;
penSize = 1;
pattern0 = B_SOLID_HIGH;
fontSpacing = B_STRING_SPACING;
}
State(State *prev)
{
*this = *prev;
this->prev = prev;
}
};
class Font
{
public:
Font(char *n, int f, font_encoding e) : name(n), font(f), encoding(e) { }
BString name;
int font;
font_encoding encoding;
};
class Pattern
{
public:
pattern pat;
rgb_color lowColor, highColor;
int patternId;
Pattern(const pattern &p, rgb_color low, rgb_color high, int id)
: pat(p)
, lowColor(low)
, highColor(high)
, patternId(id)
{};
inline bool Matches(const pattern &p, rgb_color low, rgb_color high) const {
return IsSame(pat, p) && IsSame(lowColor, low) && IsSame(highColor, high);
};
};
class Transparency
{
uint8 alpha;
int handle;
public:
Transparency(uint8 alpha, int handle)
: alpha(alpha)
, handle(handle)
{};
inline bool Matches(uint8 alpha) const {
return this->alpha == alpha;
};
inline int Handle() const { return handle; }
};
PDFVersion fPDFVersion;
FILE *fLog;
PDF *fPdf;
int32 fPage;
State *fState;
int32 fStateDepth;
TList<Font> fFontCache;
TList<Pattern> fPatterns;
TList<Transparency> fTransparencyCache;
TList<Transparency> fTransparencyStack;
ImageCache fImageCache;
int64 fEmbedMaxFontSize;
BScreen *fScreen;
Fonts *fFonts;
bool fCreateWebLinks;
bool fCreateBookmarks;
Bookmark *fBookmark;
bool fCreateXRefs;
XRefDefs *fXRefs;
XRefDests *fXRefDests;
font_encoding fFontSearchOrder[no_of_cjk_encodings];
TextLine fTextLine;
TList<UsedFont> fUsedFonts;
UserDefinedEncodings fUserDefinedEncodings;
enum
{
kDrawingMode,
kClippingMode
} fMode;
inline float tx(float x) { return fState->pdfSystem.tx(x); }
inline float ty(float y) { return fState->pdfSystem.ty(y); }
inline float scale(float f) { return fState->pdfSystem.scale(f); }
PDFSystem* pdfSystem() const { return &fState->pdfSystem; }
enum
{
kStroke = true,
kFill = false
};
inline bool MakesPattern() { return Pass() == 0; }
inline bool MakesPDF() { return Pass() == 1; }
inline bool IsDrawing() const { return fMode == kDrawingMode; }
inline bool IsClipping() const { return fMode == kClippingMode; }
// PDF features depending on PDF version:
inline bool SupportsSoftMask() const { return fPDFVersion >= kPDF14; }
inline bool SupportsOpacity() const { return fPDFVersion >= kPDF14; }
inline float PenSize() const { return fState->penSize; }
inline cap_mode LineCapMode() const { return fState->capMode; }
inline join_mode LineJoinMode() const { return fState->joinMode; }
inline float LineMiterLimit() const { return fState->miterLimit; }
bool StoreTranslatorBitmap(BBitmap *bitmap, const char *filename, uint32 type);
void GetFontName(BFont *font, char *fontname);
void GetFontName(BFont *font, char *fontname, bool &embed, font_encoding encoding);
int FindFont(char *fontname, bool embed, font_encoding encoding);
void MakeUserDefinedEncoding(uint16 unicode, uint8 &enc, uint8 &index);
// alpha transparency
Transparency* FindTransparency(uint8 alpha);
void BeginTransparency();
void EndTransparency();
void PushInternalState();
bool PopInternalState();
void SetColor(rgb_color toSet);
void SetColor();
void CreatePattern();
int FindPattern();
void SetPattern();
void StrokeOrClip();
void FillOrClip();
void Paint(bool stroke);
void PaintShape(BShape *shape, bool stroke);
void PaintRoundRect(BRect rect, BPoint radii, bool stroke);
void PaintArc(BPoint center, BPoint radii, float startTheta, float arcTheta, int stroke);
void PaintEllipse(BPoint center, BPoint radii, bool stroke);
};
inline bool
PDFWriter::IsSame(const pattern &p1, const pattern &p2)
{
char *a = (char*)p1.data;
char *b = (char*)p2.data;
return memcmp(a, b, 8) == 0;
}
inline bool
PDFWriter::IsSame(const rgb_color &c1, const rgb_color &c2)
{
char *a = (char*)&c1;
char *b = (char*)&c1;
return memcmp(a, b, sizeof(rgb_color)) == 0;
}
// PDFLib C callbacks class instance redirectors
size_t _WriteData(PDF *p, void *data, size_t size);
void _ErrorHandler(PDF *p, int type, const char *msg);
#endif // PDFWRITER_H
@@ -1,78 +0,0 @@
/*
** PDFWriter.rdef
**
*/
/* BEOS:APP_SIG :
application:/x-vnd.obos.app-name
*/
resource app_signature "application/x-vnd.obos.pdfwriter";
/* BEOS:APP_FLAGS :
00000000 = SINGLE LAUNCH
00000001 = MULTIPLE LAUNCH
00000002 = EXCLUSIVE LAUNCH
00000004 = BACKGROUND APP + SINGLE LAUNCH
00000005 = BACKGROUND APP + MULTIPLE LAUNCH
00000006 = BACKGROUND APP + EXCLUSIVE LAUNCH
00000008 = ARGV_ONLY + SINGLE LAUNCH
00000009 = ARGV_ONLY + MULTIPLE LAUNCH
0000000A = ARGV_ONLY + EXCLUSIVE LAUNCH
0000000C = ARGV_ONLY + BACKGROUND APP + SINGLE LAUNCH
0000000D = ARGV_ONLY + BACKGROUND APP + MULTIPLE LAUNCH
0000000E = ARGV_ONLY + BACKGROUND APP + EXCLUSIVE LAUNCH
*/
resource app_flags B_SINGLE_LAUNCH;
/* BEOS:FILE_TYPES :
"types" = "text/plain",
"types" = ....
*/
resource app_version {
major = 2,
middle = 0,
minor = 1,
/* 0 = development 1 = alpha 2 = beta
3 = gamma 4 = golden master 5 = final */
variety = 2,
internal = 1,
short_info = "v2.0 Beta 1",
long_info = "v2.0 Beta 1. Copyrights (©) 2002-2003 OpenBeOS"
};
resource vector_icon {
$"6E6369660F050002001602B76E70BBF8583D120FB8A7674742A04ABEFB00AEFF"
$"E1053802001603373333B9333339333337333348E54F4B555400FFBFE5FF9B02"
$"00160336C6F3B9284239E396376BBA4A71BE484A25005346B5FFFF02001602B5"
$"00003A6000BA6000B500004A2E244AB9D001C0FF9A020116023AA41339C70ABC"
$"27003D026D4ACAB74AC8AB0183FFAD020106023600000000000000003700004A"
$"10004AB0000035FF06FB1E9303020106023600000000000000003700004A1000"
$"4AB00000FFE3E3FFDD05050101000073020116023E1E40BC9E383B21B93C88A5"
$"4824E3485D850090FF3C0501020006023B61A038E755B9F2003C4C154AC9623D"
$"6A0500FF6D6DFFDA1C1C05FF0200060239658D3E8928BDB2D1387A224A4B6346"
$"066BFF1467FF6B06F8B7110606BE023A5F485C46584C5E5656525A5656604C58"
$"483A0608EFB6302E302E25372248223A2248465A4A59485B4A59584B41573E58"
$"3F563D543C0608AAFF503A4E3C3231342F302E302E25372248223A2248465A46"
$"5A464C543C4A46543C0606FF06573E583F563D543C543C4A46465A464C465A4A"
$"59485B4A59584B410604DB4A594A4F4A59584B41563F563F4E470A0426484256"
$"4252264406057A0322513A5E42543C58425452B77BC262B77BC262254A080226"
$"502C530A06542A3C22353135324C3B4C3A0202404A3E4C4248434D454B414F02"
$"0332332B3332334B3E4B3E453E3547444E26400606F60F3E3022492444244D24"
$"5A2255225A225A305A30553049324D3244320803522E522756270404B6412E27"
$"45294526452C422B0604F649272E4E2C4E2F4E2C4E294EB71B4E260802522B55"
$"2B0604FA2F3B42444E37483AC5AFBBFC3B2FBE1DB8CC3532150A090100000A00"
$"030806011001178400040A010102000A0001051001178200040A020105000A03"
$"0106000A040108000A050103000A060104000A08010920251C0A070109202221"
$"0A00010730241C01178100040A00010730221E01178100040A0001071815FF01"
$"178100040A0A010A000A0E0110023DCCCC0000000000003E00004599994A7000"
$"0A0B01101A3DCCCC0000000000003E00004599994A700026FF01178100040A0B"
$"01101A3DCCCC0000000000003E00004599994A7000152601178200040A0B010B"
$"30244C01178402040A0C010B20244C0A0D040C0D0E0F38244C15FF0117822204"
};
@@ -1,420 +0,0 @@
/*
PDF Writer printer driver.
Version: 12.19.2000
Copyright (c) 2001 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "PageSetupWindow.h"
#include "AdvancedSettingsWindow.h"
#include "Fonts.h"
#include "FontsWindow.h"
#include "BlockingWindow.h"
#include "MarginView.h"
#include "PrinterDriver.h"
#include "pdflib.h" // for pageFormat constants
#include "PrintUtils.h"
#include <Button.h>
#include <LayoutBuilder.h>
#include <MenuField.h>
#include <Message.h>
#include <PopUpMenu.h>
#include <SeparatorView.h>
#include <Screen.h>
#include <TextControl.h>
// static global variables
static struct
{
const char *label;
float width;
float height;
} pageFormat[] =
{
{ "Letter", letter_width, letter_height },
{ "Legal", legal_width, legal_height },
{ "Ledger", ledger_width, ledger_height },
{ "p11x17", p11x17_width, p11x17_height },
{ "A0", a0_width, a0_height },
{ "A1", a1_width, a1_height },
{ "A2", a2_width, a2_height },
{ "A3", a3_width, a3_height },
{ "A4", a4_width, a4_height },
{ "A5", a5_width, a5_height },
{ "A6", a6_width, a6_height },
{ "B5", b5_width, b5_height },
{ NULL, 0.0, 0.0 }
};
static struct
{
const char *label;
int32 orientation;
} orientation[] =
{
{ "Portrait", PrinterDriver::PORTRAIT_ORIENTATION },
{ "Landscape", PrinterDriver::LANDSCAPE_ORIENTATION },
{ NULL, 0 }
};
// PDFLib 5.x does not support PDF 1.2 anymore!
static const char *pdf_compatibility[] = { "1.3", "1.4", NULL };
PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
: HWindow(BRect(0, 0, 200, 100), "Paper setup", B_TITLED_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
fResult(B_ERROR),
fSetupMsg(msg),
fAdvancedSettings(*msg),
fPrinterDirName(printerName)
{
fExitSem = create_sem(0, "PageSetup");
if (printerName)
SetTitle(BString(printerName).Append(" paper setup").String());
if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK)
fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION;
BRect page;
float width = letter_width;
float height = letter_height;
if (fSetupMsg->FindRect("paper_rect", &page) == B_OK) {
width = page.Width();
height = page.Height();
} else {
page.Set(0, 0, width, height);
}
BString label;
if (fSetupMsg->FindString("pdf_paper_size", &label) != B_OK)
label = "Letter";
int32 compression;
fSetupMsg->FindInt32("pdf_compression", &compression);
int32 units;
if (fSetupMsg->FindInt32("units", &units) != B_OK)
units = kUnitInch;
// re-calculate the margin from the printable rect in points
BRect margin = page;
if (fSetupMsg->FindRect("printable_rect", &margin) == B_OK) {
margin.top -= page.top;
margin.left -= page.left;
margin.right = page.right - margin.right;
margin.bottom = page.bottom - margin.bottom;
} else {
margin.Set(28.34, 28.34, 28.34, 28.34); // 28.34 dots = 1cm
}
BString setting_value;
if (fSetupMsg->FindString("pdf_compatibility", &setting_value) != B_OK)
setting_value = "1.3";
// Load font settings
fFonts = new Fonts();
fFonts->CollectFonts();
BMessage fonts;
if (fSetupMsg->FindMessage("fonts", &fonts) == B_OK)
fFonts->SetTo(&fonts);
fMarginView = new MarginView(int32(width), int32(height), margin,
MarginUnit(units));
BPopUpMenu* pageSize = new BPopUpMenu("Page size");
pageSize->SetRadioMode(true);
fPageSizeMenu = new BMenuField("page_size", "Page size:", pageSize);
fPageSizeMenu->Menu()->SetLabelFromMarked(true);
for (int32 i = 0; pageFormat[i].label != NULL; i++) {
BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
message->AddFloat("width", pageFormat[i].width);
message->AddFloat("height", pageFormat[i].height);
BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
pageSize->AddItem(item);
if (label.Compare(pageFormat[i].label) == 0)
item->SetMarked(true);
}
BPopUpMenu* orientationPopUpMenu = new BPopUpMenu("Orientation");
orientationPopUpMenu->SetRadioMode(true);
fOrientationMenu = new BMenuField("orientation", "Orientation:",
orientationPopUpMenu);
fOrientationMenu->Menu()->SetLabelFromMarked(true);
for (int32 i = 0; orientation[i].label != NULL; i++) {
BMessage* message = new BMessage(ORIENTATION_CHANGED);
message->AddInt32("orientation", orientation[i].orientation);
BMenuItem* item = new BMenuItem(orientation[i].label, message);
orientationPopUpMenu->AddItem(item);
if (fCurrentOrientation == orientation[i].orientation)
item->SetMarked(true);
}
BPopUpMenu* compatibility = new BPopUpMenu("PDF compatibility");
compatibility->SetRadioMode(true);
fPDFCompatibilityMenu = new BMenuField("pdf_compatibility",
"PDF compatibility:", compatibility);
fPDFCompatibilityMenu->Menu()->SetLabelFromMarked(true);
for (int32 i = 0; pdf_compatibility[i] != NULL; i++) {
BMenuItem* item = new BMenuItem(pdf_compatibility[i], NULL);
compatibility->AddItem(item);
if (setting_value == pdf_compatibility[i])
item->SetMarked(true);
}
fPDFCompressionSlider = new BSlider("pdf_compression",
"Compression:", NULL, 0, 9, B_HORIZONTAL);
fPDFCompressionSlider->SetLimitLabels("None", "Best");
fPDFCompressionSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fPDFCompressionSlider->SetValue(compression);
BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG));
BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG));
ok->MakeDefault(true);
BButton *fontsButton = new BButton("fonts", "Fonts" B_UTF8_ELLIPSIS,
new BMessage(FONTS_MSG));
BButton* advancedButton = new BButton("advanced",
"Advanced" B_UTF8_ELLIPSIS,
new BMessage(ADVANCED_MSG));
float padding = 10;
BLayoutBuilder::Group<>(this, B_VERTICAL, padding)
.SetInsets(B_USE_DEFAULT_SPACING)
.AddGroup(B_HORIZONTAL, 5, 1)
.AddGroup(B_VERTICAL, 0, 1.0f)
.Add(fMarginView)
.End()
.AddGrid(padding, padding / 2)
.SetInsets(padding, padding * 2, padding, padding)
.Add(fPageSizeMenu->CreateLabelLayoutItem(), 0, 0)
.Add(fPageSizeMenu->CreateMenuBarLayoutItem(), 1, 0)
.Add(fOrientationMenu->CreateLabelLayoutItem(), 0, 1)
.Add(fOrientationMenu->CreateMenuBarLayoutItem(), 1, 1)
.Add(fPDFCompatibilityMenu->CreateLabelLayoutItem(), 0, 2)
.Add(fPDFCompatibilityMenu->CreateMenuBarLayoutItem(), 1, 2)
.Add(fPDFCompressionSlider, 0, 3, 2)
.End()
.End()
.Add(new BSeparatorView(B_HORIZONTAL, B_FANCY_BORDER))
.AddGroup(B_HORIZONTAL, 10, 1.0f)
.Add(fontsButton)
.Add(advancedButton)
.AddGlue()
.Add(cancel)
.Add(ok)
.End();
BRect winFrame(Frame());
BRect screenFrame(BScreen().Frame());
MoveTo((screenFrame.right - winFrame.right) / 2,
(screenFrame.bottom - winFrame.bottom) / 2);
}
PageSetupWindow::~PageSetupWindow()
{
delete_sem(fExitSem);
delete fFonts;
}
void
PageSetupWindow::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case OK_MSG: {
_UpdateSetupMessage();
fResult = B_OK;
release_sem(fExitSem);
} break;
case CANCEL_MSG: {
fResult = B_ERROR;
release_sem(fExitSem);
} break;
case PAGE_SIZE_CHANGED: {
float w, h;
msg->FindFloat("width", &w);
msg->FindFloat("height", &h);
if (fCurrentOrientation == PrinterDriver::PORTRAIT_ORIENTATION) {
fMarginView->SetPageSize(w, h);
} else {
fMarginView->SetPageSize(h, w);
}
fMarginView->UpdateView(MARGIN_CHANGED);
} break;
case ORIENTATION_CHANGED: {
int32 orientation;
msg->FindInt32("orientation", &orientation);
if (fCurrentOrientation != orientation) {
fCurrentOrientation = orientation;
BPoint p = fMarginView->PageSize();
fMarginView->SetPageSize(p.y, p.x);
fMarginView->UpdateView(MARGIN_CHANGED);
}
} break;
case FONTS_MSG: {
(new FontsWindow(fFonts))->Show();
} break;
case ADVANCED_MSG: {
(new AdvancedSettingsWindow(&fAdvancedSettings))->Show();
} break;
default:
inherited::MessageReceived(msg);
break;
}
}
bool
PageSetupWindow::QuitRequested()
{
release_sem(fExitSem);
return true;
}
status_t
PageSetupWindow::Go()
{
MoveTo(300,300);
Show();
while (acquire_sem(fExitSem) == B_INTERRUPTED) {
}
// Have to cache the value since we delete ourself on Quit()
status_t result = fResult;
if (Lock())
Quit();
return result;
}
void
PageSetupWindow::_UpdateSetupMessage()
{
SetInt32(fSetupMsg, "orientation", fCurrentOrientation);
BMenuItem *item = fPDFCompatibilityMenu->Menu()->FindMarked();
if (item)
SetString(fSetupMsg, "pdf_compatibility", item->Label());
SetInt32(fSetupMsg, "pdf_compression", fPDFCompressionSlider->Value());
item = fPageSizeMenu->Menu()->FindMarked();
if (item) {
float w, h;
BMessage *msg = item->Message();
msg->FindFloat("width", &w);
msg->FindFloat("height", &h);
BRect r(0, 0, w, h);
if (fCurrentOrientation == PrinterDriver::LANDSCAPE_ORIENTATION)
r.Set(0, 0, h, w);
// Save the printable_rect
BRect margin = fMarginView->Margin();
if (fCurrentOrientation == PrinterDriver::PORTRAIT_ORIENTATION) {
margin.right = w - margin.right;
margin.bottom = h - margin.bottom;
} else {
margin.right = h - margin.right;
margin.bottom = w - margin.bottom;
}
SetRect(fSetupMsg, "paper_rect", r);
SetRect(fSetupMsg, "printable_rect", margin);
SetInt32(fSetupMsg, "units", fMarginView->Unit());
SetString(fSetupMsg, "pdf_paper_size", item->Label());
}
BMessage fonts;
if (fFonts->Archive(&fonts) == B_OK) {
fSetupMsg->RemoveName("fonts");
fSetupMsg->AddMessage("fonts", &fonts);
}
// advanced settings
BString value;
if (fAdvancedSettings.FindString("pdflib_license_key", &value) == B_OK)
SetString(fSetupMsg, "pdflib_license_key", value);
bool webLinks;
if (fAdvancedSettings.FindBool("create_web_links", &webLinks) == B_OK)
SetBool(fSetupMsg, "create_web_links", webLinks);
float linkBorder;
if (fAdvancedSettings.FindFloat("link_border_width", &linkBorder) == B_OK)
SetFloat(fSetupMsg, "link_border_width", linkBorder);
bool createBookmarks;
if (fAdvancedSettings.FindBool("create_bookmarks", &createBookmarks) == B_OK)
SetBool(fSetupMsg, "create_bookmarks", createBookmarks);
if (fAdvancedSettings.FindString("bookmark_definition_file", &value) == B_OK)
SetString(fSetupMsg, "bookmark_definition_file", value);
bool createXrefs;
if (fAdvancedSettings.FindBool("create_xrefs", &createXrefs) == B_OK)
SetBool(fSetupMsg, "create_xrefs", createXrefs);
if (fAdvancedSettings.FindString("xrefs_file", &value) == B_OK)
SetString(fSetupMsg, "xrefs_file", value.String());
int32 closeOption;
if (fAdvancedSettings.FindInt32("close_option", &closeOption) == B_OK)
SetInt32(fSetupMsg, "close_option", closeOption);
}
@@ -1,91 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef PAGESETUPWINDOW_H
#define PAGESETUPWINDOW_H
#include "BlockingWindow.h"
#include <Message.h>
#include <String.h>
class BMenuField;
class BSlider;
class Fonts;
class MarginView;
class PageSetupWindow : public HWindow
{
typedef HWindow inherited;
public:
// Constructors, destructors, operators...
PageSetupWindow(BMessage *msg, const char *printerName = NULL);
~PageSetupWindow();
virtual void MessageReceived(BMessage *msg);
virtual bool QuitRequested();
status_t Go();
enum {
OK_MSG = 'ok__',
CANCEL_MSG = 'cncl',
FONTS_MSG = 'font',
ADVANCED_MSG = 'advc',
PAGE_SIZE_CHANGED = 'pgsz',
ORIENTATION_CHANGED = 'ornt'
};
private:
void _UpdateSetupMessage();
private:
long fExitSem;
status_t fResult;
BMessage* fSetupMsg;
BMenuField* fPageSizeMenu;
BMenuField* fOrientationMenu;
BMenuField* fPDFCompatibilityMenu;
BSlider* fPDFCompressionSlider;
Fonts* fFonts;
BMessage fAdvancedSettings;
MarginView * fMarginView;
// used for saving settings
BString fPrinterDirName;
int32 fCurrentOrientation;
};
#endif
@@ -1,151 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001, 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "PictureIterator.h"
// BPicture playback handlers class instance redirectors
static void _MovePenBy(void *p, BPoint delta) { return ((PictureIterator *) p)->MovePenBy(delta); }
static void _StrokeLine(void *p, BPoint start, BPoint end) { return ((PictureIterator *) p)->StrokeLine(start, end); }
static void _StrokeRect(void *p, BRect rect) { return ((PictureIterator *) p)->StrokeRect(rect); }
static void _FillRect(void *p, BRect rect) { return ((PictureIterator *) p)->FillRect(rect); }
static void _StrokeRoundRect(void *p, BRect rect, BPoint radii) { return ((PictureIterator *) p)->StrokeRoundRect(rect, radii); }
static void _FillRoundRect(void *p, BRect rect, BPoint radii) { return ((PictureIterator *) p)->FillRoundRect(rect, radii); }
static void _StrokeBezier(void *p, BPoint *control) { return ((PictureIterator *) p)->StrokeBezier(control); }
static void _FillBezier(void *p, BPoint *control) { return ((PictureIterator *) p)->FillBezier(control); }
static void _StrokeArc(void *p, BPoint center, BPoint radii, float startTheta, float arcTheta) { return ((PictureIterator *) p)->StrokeArc(center, radii, startTheta, arcTheta); }
static void _FillArc(void *p, BPoint center, BPoint radii, float startTheta, float arcTheta) { return ((PictureIterator *) p)->FillArc(center, radii, startTheta, arcTheta); }
static void _StrokeEllipse(void *p, BPoint center, BPoint radii) { return ((PictureIterator *) p)->StrokeEllipse(center, radii); }
static void _FillEllipse(void *p, BPoint center, BPoint radii) { return ((PictureIterator *) p)->FillEllipse(center, radii); }
static void _StrokePolygon(void *p, int32 numPoints, BPoint *points, bool isClosed) { return ((PictureIterator *) p)->StrokePolygon(numPoints, points, isClosed); }
static void _FillPolygon(void *p, int32 numPoints, BPoint *points, bool isClosed) { return ((PictureIterator *) p)->FillPolygon(numPoints, points, isClosed); }
static void _StrokeShape(void * p, BShape *shape) { return ((PictureIterator *) p)->StrokeShape(shape); }
static void _FillShape(void * p, BShape *shape) { return ((PictureIterator *) p)->FillShape(shape); }
static void _DrawString(void *p, char *string, float deltax, float deltay) { return ((PictureIterator *) p)->DrawString(string, deltax, deltay); }
static void _DrawPixels(void *p, BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data)
{ return ((PictureIterator *) p)->DrawPixels(src, dest, width, height, bytesPerRow, pixelFormat, flags, data); }
static void _SetClippingRects(void *p, BRect *rects, uint32 numRects) { return ((PictureIterator *) p)->SetClippingRects(rects, numRects); }
static void _ClipToPicture(void * p, BPicture *picture, BPoint point, bool clip_to_inverse_picture) { return ((PictureIterator *) p)->ClipToPicture(picture, point, clip_to_inverse_picture); }
static void _PushState(void *p) { return ((PictureIterator *) p)->PushState(); }
static void _PopState(void *p) { return ((PictureIterator *) p)->PopState(); }
static void _EnterStateChange(void *p) { return ((PictureIterator *) p)->EnterStateChange(); }
static void _ExitStateChange(void *p) { return ((PictureIterator *) p)->ExitStateChange(); }
static void _EnterFontState(void *p) { return ((PictureIterator *) p)->EnterFontState(); }
static void _ExitFontState(void *p) { return ((PictureIterator *) p)->ExitFontState(); }
static void _SetOrigin(void *p, BPoint pt) { return ((PictureIterator *) p)->SetOrigin(pt); }
static void _SetPenLocation(void *p, BPoint pt) { return ((PictureIterator *) p)->SetPenLocation(pt); }
static void _SetDrawingMode(void *p, drawing_mode mode) { return ((PictureIterator *) p)->SetDrawingMode(mode); }
static void _SetLineMode(void *p, cap_mode capMode, join_mode joinMode, float miterLimit) { return ((PictureIterator *) p)->SetLineMode(capMode, joinMode, miterLimit); }
static void _SetPenSize(void *p, float size) { return ((PictureIterator *) p)->SetPenSize(size); }
static void _SetForeColor(void *p, rgb_color color) { return ((PictureIterator *) p)->SetForeColor(color); }
static void _SetBackColor(void *p, rgb_color color) { return ((PictureIterator *) p)->SetBackColor(color); }
static void _SetStipplePattern(void *p, pattern pat) { return ((PictureIterator *) p)->SetStipplePattern(pat); }
static void _SetScale(void *p, float scale) { return ((PictureIterator *) p)->SetScale(scale); }
static void _SetFontFamily(void *p, char *family) { return ((PictureIterator *) p)->SetFontFamily(family); }
static void _SetFontStyle(void *p, char *style) { return ((PictureIterator *) p)->SetFontStyle(style); }
static void _SetFontSpacing(void *p, int32 spacing) { return ((PictureIterator *) p)->SetFontSpacing(spacing); }
static void _SetFontSize(void *p, float size) { return ((PictureIterator *) p)->SetFontSize(size); }
static void _SetFontRotate(void *p, float rotation) { return ((PictureIterator *) p)->SetFontRotate(rotation); }
static void _SetFontEncoding(void *p, int32 encoding) { return ((PictureIterator *) p)->SetFontEncoding(encoding); }
static void _SetFontFlags(void *p, int32 flags) { return ((PictureIterator *) p)->SetFontFlags(flags); }
static void _SetFontShear(void *p, float shear) { return ((PictureIterator *) p)->SetFontShear(shear); }
static void _SetFontFace(void * p, int32 flags) { return ((PictureIterator *) p)->SetFontFace(flags); }
// undefined or undocumented operation handlers...
static void _op0(void * p) { return ((PictureIterator *) p)->Op(0); }
static void _op19(void * p) { return ((PictureIterator *) p)->Op(19); }
static void _op45(void * p) { return ((PictureIterator *) p)->Op(45); }
static void _op47(void * p) { return ((PictureIterator *) p)->Op(47); }
static void _op48(void * p) { return ((PictureIterator *) p)->Op(48); }
static void _op49(void * p) { return ((PictureIterator *) p)->Op(49); }
// Private Variables
// -----------------
static void *
playbackHandlers[] = {
(void*)_op0, // 0 no operation
(void*)_MovePenBy, // 1 MovePenBy(void *user, BPoint delta)
(void*)_StrokeLine, // 2 StrokeLine(void *user, BPoint start, BPoint end)
(void*)_StrokeRect, // 3 StrokeRect(void *user, BRect rect)
(void*)_FillRect, // 4 FillRect(void *user, BRect rect)
(void*)_StrokeRoundRect, // 5 StrokeRoundRect(void *user, BRect rect, BPoint radii)
(void*)_FillRoundRect, // 6 FillRoundRect(void *user, BRect rect, BPoint radii)
(void*)_StrokeBezier, // 7 StrokeBezier(void *user, BPoint *control)
(void*)_FillBezier, // 8 FillBezier(void *user, BPoint *control)
(void*)_StrokeArc, // 9 StrokeArc(void *user, BPoint center, BPoint radii, float startTheta, float arcTheta)
(void*)_FillArc, // 10 FillArc(void *user, BPoint center, BPoint radii, float startTheta, float arcTheta)
(void*)_StrokeEllipse, // 11 StrokeEllipse(void *user, BPoint center, BPoint radii)
(void*)_FillEllipse, // 12 FillEllipse(void *user, BPoint center, BPoint radii)
(void*)_StrokePolygon, // 13 StrokePolygon(void *user, int32 numPoints, BPoint *points, bool isClosed)
(void*)_FillPolygon, // 14 FillPolygon(void *user, int32 numPoints, BPoint *points, bool isClosed)
(void*)_StrokeShape, // 15 StrokeShape(void *user, BShape *shape)
(void*)_FillShape, // 16 FillShape(void *user, BShape *shape)
(void*)_DrawString, // 17 DrawString(void *user, char *string, float deltax, float deltay)
(void*)_DrawPixels, // 18 DrawPixels(void *user, BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data)
(void*)_op19, // 19 *reserved*
(void*)_SetClippingRects, // 20 SetClippingRects(void *user, BRect *rects, uint32 numRects)
(void*)_ClipToPicture, // 21 ClipToPicture(void *user, BPicture *picture, BPoint pt, bool clip_to_inverse_picture)
(void*)_PushState, // 22 PushState(void *user)
(void*)_PopState, // 23 PopState(void *user)
(void*)_EnterStateChange, // 24 EnterStateChange(void *user)
(void*)_ExitStateChange, // 25 ExitStateChange(void *user)
(void*)_EnterFontState, // 26 EnterFontState(void *user)
(void*)_ExitFontState, // 27 ExitFontState(void *user)
(void*)_SetOrigin, // 28 SetOrigin(void *user, BPoint pt)
(void*)_SetPenLocation, // 29 SetPenLocation(void *user, BPoint pt)
(void*)_SetDrawingMode, // 30 SetDrawingMode(void *user, drawing_mode mode)
(void*)_SetLineMode, // 31 SetLineMode(void *user, cap_mode capMode, join_mode joinMode, float miterLimit)
(void*)_SetPenSize, // 32 SetPenSize(void *user, float size)
(void*)_SetForeColor, // 33 SetForeColor(void *user, rgb_color color)
(void*)_SetBackColor, // 34 SetBackColor(void *user, rgb_color color)
(void*)_SetStipplePattern, // 35 SetStipplePattern(void *user, pattern p)
(void*)_SetScale, // 36 SetScale(void *user, float scale)
(void*)_SetFontFamily, // 37 SetFontFamily(void *user, char *family)
(void*)_SetFontStyle, // 38 SetFontStyle(void *user, char *style)
(void*)_SetFontSpacing, // 39 SetFontSpacing(void *user, int32 spacing)
(void*)_SetFontSize, // 40 SetFontSize(void *user, float size)
(void*)_SetFontRotate, // 41 SetFontRotate(void *user, float rotation)
(void*)_SetFontEncoding, // 42 SetFontEncoding(void *user, int32 encoding)
(void*)_SetFontFlags, // 43 SetFontFlags(void *user, int32 flags)
(void*)_SetFontShear, // 44 SetFontShear(void *user, float shear)
(void*)_op45, // 45 *reserved*
(void*)_SetFontFace, // 46 SetFontFace(void *user, int32 flags)
(void*)_op47,
(void*)_op48,
(void*)_op49,
NULL
};
void
PictureIterator::Iterate(BPicture* picture) {
picture->Play(playbackHandlers, 50, this);
}
@@ -1,93 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001, 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _PICTURE_ITERATOR_H
#define _PICTURE_ITERATOR_H
#include <AppKit.h>
#include <InterfaceKit.h>
class PictureIterator
{
public:
virtual ~PictureIterator() { }
// BPicture playback handlers
virtual void Op(int number) { }
virtual void MovePenBy(BPoint delta) { }
virtual void StrokeLine(BPoint start, BPoint end) { }
virtual void StrokeRect(BRect rect) { }
virtual void FillRect(BRect rect) { }
virtual void StrokeRoundRect(BRect rect, BPoint radii) { }
virtual void FillRoundRect(BRect rect, BPoint radii) { }
virtual void StrokeBezier(BPoint *control) { }
virtual void FillBezier(BPoint *control) { }
virtual void StrokeArc(BPoint center, BPoint radii, float startTheta, float arcTheta) { }
virtual void FillArc(BPoint center, BPoint radii, float startTheta, float arcTheta) { }
virtual void StrokeEllipse(BPoint center, BPoint radii) { }
virtual void FillEllipse(BPoint center, BPoint radii) { }
virtual void StrokePolygon(int32 numPoints, BPoint *points, bool isClosed) { }
virtual void FillPolygon(int32 numPoints, BPoint *points, bool isClosed) { }
virtual void StrokeShape(BShape *shape) { }
virtual void FillShape(BShape *shape) { }
virtual void DrawString(char *string, float escapement_nospace, float escapement_space) { }
virtual void DrawPixels(BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data) { }
virtual void SetClippingRects(BRect *rects, uint32 numRects) { }
virtual void ClipToPicture(BPicture *picture, BPoint point, bool clip_to_inverse_picture) { }
virtual void PushState() { }
virtual void PopState() { }
virtual void EnterStateChange() { }
virtual void ExitStateChange() { }
virtual void EnterFontState() { }
virtual void ExitFontState() { }
virtual void SetOrigin(BPoint pt) { }
virtual void SetPenLocation(BPoint pt) { }
virtual void SetDrawingMode(drawing_mode mode) { }
virtual void SetLineMode(cap_mode capMode, join_mode joinMode, float miterLimit) { }
virtual void SetPenSize(float size) { }
virtual void SetForeColor(rgb_color color) { }
virtual void SetBackColor(rgb_color color) { }
virtual void SetStipplePattern(pattern p) { }
virtual void SetScale(float scale) { }
virtual void SetFontFamily(char *family) { }
virtual void SetFontStyle(char *style) { }
virtual void SetFontSpacing(int32 spacing) { }
virtual void SetFontSize(float size) { }
virtual void SetFontRotate(float rotation) { }
virtual void SetFontEncoding(int32 encoding) { }
virtual void SetFontFlags(int32 flags) { }
virtual void SetFontShear(float shear) { }
virtual void SetFontFace(int32 flags) { }
virtual void Iterate(BPicture* picture);
};
#endif // _PICTURE_ITERATOR_H
@@ -1,265 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001-2003 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h> // for memset()
#include <StorageKit.h>
#include "PrinterDriver.h"
#include "PageSetupWindow.h"
#include "JobSetupWindow.h"
#include "StatusWindow.h"
#include "PrinterSettings.h"
#include "Report.h"
// Private prototypes
// ------------------
#ifdef CODEWARRIOR
#pragma mark [Constructor & destructor]
#endif
// Constructor & destructor
// ------------------------
// --------------------------------------------------
PrinterDriver::PrinterDriver()
: fJobFile(NULL),
fPrinterNode(NULL),
fJobMsg(NULL)
{
}
// --------------------------------------------------
PrinterDriver::~PrinterDriver()
{
}
#ifdef CODEWARRIOR
#pragma mark [Public methods]
#endif
#ifdef B_BEOS_VERSION_DANO
struct print_file_header {
int32 version;
int32 page_count;
off_t first_page;
int32 _reserved_3_;
int32 _reserved_4_;
int32 _reserved_5_;
};
#endif
// Public methods
// --------------
status_t
PrinterDriver::PrintJob
(
BFile *jobFile, // spool file
BNode *printerNode, // printer node, used by OpenTransport() to find & load transport add-on
BMessage *jobMsg // job message
)
{
print_file_header pfh;
status_t status;
BMessage *msg;
int32 page;
uint32 copy;
uint32 copies;
const int32 passes = 2;
fJobFile = jobFile;
fPrinterNode = printerNode;
fJobMsg = jobMsg;
if (!fJobFile || !fPrinterNode)
return B_ERROR;
if (fPrintTransport.Open(fPrinterNode) != B_OK) {
return B_ERROR;
}
if (fPrintTransport.IsPrintToFileCanceled()) {
return B_OK;
}
// read print file header
fJobFile->Seek(0, SEEK_SET);
fJobFile->Read(&pfh, sizeof(pfh));
// read job message
fJobMsg = msg = new BMessage();
msg->Unflatten(fJobFile);
// We have to load the settings here for Dano/Zeta because they don't store
// all fields from the message returned by config_job in the job file!
PrinterSettings::Read(printerNode, msg, PrinterSettings::kJobSettings);
if (msg->HasInt32("copies")) {
copies = msg->FindInt32("copies");
} else {
copies = 1;
}
// force creation of Report object
Report::Instance();
// show status window
StatusWindow* statusWindow = new StatusWindow(passes, pfh.page_count, this);
status = BeginJob();
fPrinting = true;
for (fPass = 0; fPass < passes && status == B_OK && fPrinting; fPass++) {
for (copy = 0; copy < copies && status == B_OK && fPrinting; copy++)
{
for (page = 1; page <= pfh.page_count && status == B_OK && fPrinting; page++) {
statusWindow->NextPage();
status = PrintPage(page, pfh.page_count);
}
// re-read job message for next page
fJobFile->Seek(sizeof(pfh), SEEK_SET);
msg->Unflatten(fJobFile);
}
}
status_t s = EndJob();
if (status == B_OK) status = s;
delete fJobMsg;
// close status window
if (Report::Instance()->CountItems() != 0) {
statusWindow->WaitForClose();
}
if (statusWindow->Lock()) {
statusWindow->Quit();
}
// delete Report object
Report::Instance()->Free();
return status;
}
/**
* This will stop the printing loop
*
* @param none
* @return void
*/
void
PrinterDriver::StopPrinting()
{
fPrinting = false;
}
// --------------------------------------------------
status_t
PrinterDriver::BeginJob()
{
return B_OK;
}
// --------------------------------------------------
status_t
PrinterDriver::PrintPage(int32 pageNumber, int32 pageCount)
{
char text[128];
sprintf(text, "Faking print of page %" B_PRId32 "/%" B_PRId32 "...", pageNumber, pageCount);
BAlert *alert = new BAlert("PrinterDriver::PrintPage()", text, "Hmm?");
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
return B_OK;
}
// --------------------------------------------------
status_t
PrinterDriver::EndJob()
{
return B_OK;
}
// --------------------------------------------------
status_t
PrinterDriver::PrinterSetup(char *printerName)
// name of printer, to attach printer settings
{
return B_OK;
}
// --------------------------------------------------
status_t
PrinterDriver::PageSetup(BMessage *setupMsg, const char *printerName)
{
PageSetupWindow *psw;
psw = new PageSetupWindow(setupMsg, printerName);
return psw->Go();
}
// --------------------------------------------------
status_t
PrinterDriver::JobSetup(BMessage *jobMsg, const char *printerName)
{
// set default value if property not set
if (!jobMsg->HasInt32("copies"))
jobMsg->AddInt32("copies", 1);
if (!jobMsg->HasInt32("first_page"))
jobMsg->AddInt32("first_page", 1);
if (!jobMsg->HasInt32("last_page"))
jobMsg->AddInt32("last_page", MAX_INT32);
JobSetupWindow * jsw;
jsw = new JobSetupWindow(jobMsg, printerName);
return jsw->Go();
}
#ifdef CODEWARRIOR
#pragma mark [Privates routines]
#endif
// Private routines
// ----------------
@@ -1,116 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001-2003 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _PRINTER_DRIVER_H
#define _PRINTER_DRIVER_H
#include <AppKit.h>
#include <InterfaceKit.h>
#include "PrintTransport.h"
class BNode;
#ifndef ROUND_UP
#define ROUND_UP(x, y) (((x) + (y) - 1) & ~((y) - 1))
#endif
#define MAX_INT32 ((int32)0x7fffffffL)
// transport add-on calls definition
extern "C" {
typedef BDataIO *(*init_transport_proc)(BMessage *);
typedef void (*exit_transport_proc)(void);
};
// close StatusWindow after pdf generation
enum CloseOption {
kAlways,
kNoErrors,
kNoErrorsOrWarnings,
kNoErrorsWarningsOrInfo,
kNever,
};
/**
* Class PrinterDriver
*/
class PrinterDriver
{
public:
// constructors / destructor
PrinterDriver();
virtual ~PrinterDriver();
void StopPrinting();
virtual status_t PrintJob(BFile *jobFile, BNode *printerNode, BMessage *jobMsg);
virtual status_t BeginJob();
virtual status_t PrintPage(int32 pageNumber, int32 pageCount);
virtual status_t EndJob();
// configuration default methods
virtual status_t PrinterSetup(char *printerName);
virtual status_t PageSetup(BMessage *msg, const char *printerName = NULL);
virtual status_t JobSetup(BMessage *msg, const char *printerName = NULL);
// accessors
inline BFile *JobFile() { return fJobFile; }
inline BNode *PrinterNode() { return fPrinterNode; }
inline BMessage *JobMsg() { return fJobMsg; }
inline BDataIO *Transport() { return fPrintTransport.GetDataIO(); }
inline int32 Pass() const { return fPass; }
// publics status code
typedef enum {
PORTRAIT_ORIENTATION,
LANDSCAPE_ORIENTATION
} Orientation;
private:
BFile *fJobFile;
BNode *fPrinterNode;
BMessage *fJobMsg;
volatile Orientation fOrientation;
bool fPrinting;
int32 fPass;
// transport-related
PrintTransport fPrintTransport;
};
#endif // _PRINTER_DRIVER_H
@@ -1,102 +0,0 @@
/*
PrinterPrefs.cpp
Copyright (c) 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef PRINTER_PREFS_H
#include "PrinterPrefs.h"
#endif
/**
* Constructor
*
* @param none
* @return none
*/
PrinterPrefs::PrinterPrefs()
{
}
/**
* Destructor
*
* @param none
* @return none
*/
PrinterPrefs::~PrinterPrefs()
{
}
/**
* Init the settings message from settings file
*
* @param BMessage*, the settings
* @return status_t, any result from the operation
*/
status_t
PrinterPrefs::LoadSettings(BMessage *settings)
{
status_t status;
BFile file;
status = find_directory(B_SYSTEM_SETTINGS_DIRECTORY, &fSettingsPath);
if (status != B_OK) {
// Could not find settings folder.
return status;
}
fSettingsPath.Append(SETTINGS_FILE_NAME);
status = file.SetTo(fSettingsPath.Path(), B_READ_ONLY);
if (status == B_OK) {
status = settings->Unflatten(&file);
}
return status;
}
/**
* Save the settings
*
* @param BMessage*, the settings
* @return status_t
*/
status_t
PrinterPrefs::SaveSettings(BMessage* settings)
{
status_t status;
BFile file;
status = file.SetTo(fSettingsPath.Path(), B_WRITE_ONLY | B_CREATE_FILE);
if (status == B_OK) {
return settings->Flatten(&file);
}
return status;
}
@@ -1,56 +0,0 @@
/*
PrinterPrefs.h
Copyright (c) 2002 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef PRINTER_PREFS_H
#define PRINTER_PREFS_H
#include <StorageKit.h>
#include <SupportKit.h>
const char SETTINGS_FILE_NAME[] = "pdf_printer_settings";
/**
* Class
*/
class PrinterPrefs
{
private:
BPath fSettingsPath;
public:
PrinterPrefs();
~PrinterPrefs();
status_t LoadSettings(BMessage* settings);
status_t SaveSettings(BMessage* settings);
};
#endif
@@ -1,306 +0,0 @@
/*
Printer Settings helper class
Copyright (c) 2001-2003 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "PrinterSettings.h"
#include <fs_attr.h>
#include "PrintUtils.h"
#include "PrinterPrefs.h"
/**
* Constructor
*
* @param BNode& the spooler folder
* @return void
*/
PrinterSettings::PrinterSettings(BNode &printer, Kind kind)
{
fNode = printer;
fErr = fNode.InitCheck();
fKind = kind;
}
/**
* InitCheck, check status of initialization
*
* @param none
* @return status_t the status
*/
status_t
PrinterSettings::InitCheck()
{
return fErr;
}
/**
* Destructor
*
* @param none
* @return void
*/
PrinterSettings::~PrinterSettings() { }
/**
* ReadSettings() return the settings for the printer from flattened BMessage
* attached as an attribute to the spool folder node.
*
* @param BMessage* the settings in a message object
* @return status_t the status of the read operation
*/
status_t
PrinterSettings::ReadSettings(BMessage *msg)
{
attr_info info;
char *data = NULL;
status_t err = B_ERROR;
msg->MakeEmpty();
msg->what = 0;
if (fNode.GetAttrInfo(GetAttrName(), &info) == B_OK) {
data = (char *)malloc(info.size);
if (data != NULL) {
err = fNode.ReadAttr(GetAttrName(), B_MESSAGE_TYPE, 0, data, info.size);
if (err >= 0) {
err = B_OK;
msg->Unflatten(data);
}
free(data);
}
} else { // no attributes found, then we create them
GetDefaults(msg);
WriteSettings(msg);
err = B_OK;
}
return err;
}
/**
* WriteSettings() save the settings in a flattened BMessage and attach this
* to the node as an attribute
*
* @param BMessage* the settings to save in a BMessage object
* @return status_t the status of the write operation
*/
status_t
PrinterSettings::WriteSettings(BMessage* msg)
{
ssize_t length;
char *data = NULL;
status_t err = B_ERROR;
length = msg->FlattenedSize();
if (length < 0)
return length;
data = (char *) malloc(length);
if (data != NULL) {
msg->Flatten(data, length);
err = fNode.WriteAttr(GetAttrName(), B_MESSAGE_TYPE, 0, data, length);
if (err > 0) {
err = B_OK;
}
free(data);
}
return err;
}
/**
* GetDefaults() return the default settings for the printer using:
* 1) text file pdf_printer_settings in /home/config/settings
* 2) if file not found return hard coded in this method... Yuck!
*
* @param BMessage* the settings in a message object
* @return status_t the status of the read operation
*/
status_t
PrinterSettings::GetDefaults(BMessage *msg)
{
// check to see if there is a pdf_printer_settings file
PrinterPrefs prefs;
BMessage settings;
settings.what = 'okok';
if (prefs.LoadSettings(&settings) == B_OK && Validate(&settings) == B_OK) {
// yes, copy the settings into message
*msg = settings;
} else {
// set default value if property not set
msg->AddInt64("xres", kXRes);
msg->AddInt64("yres", kYRes);
msg->AddInt32("orientation", kOrientation);
msg->AddRect("paper_rect", kPaperRect);
msg->AddRect("printable_rect", kPrintRect);
msg->AddFloat("scaling", kRes);
msg->AddString("pdf_compatibility", kPDFCompatibilty);
msg->AddInt32("pdf_compression", kPDFCompression);
msg->AddInt32("units", kUnits);
msg->AddBool("create_web_links", kCreateWebLinks);
msg->AddFloat("link_border_width", kLinkBorderWidth);
msg->AddBool("create_bookmarks", kCreateBookmarks);
msg->AddString("bookmark_definition_file", kBookmarkDefinitionFile);
msg->AddBool("create_xrefs", kCreateXRefs);
msg->AddString("xrefs_file", kXRefsFile);
msg->AddInt32("close_option", kCloseStatusWindow);
#if HAVE_FULLVERSION_PDF_LIB
msg->AddString("pdflib_license_key", kPDFLibLicenseKey);
msg->AddString("master_password", kMasterPassword);
msg->AddString("user_password", kUserPassword);
msg->AddString("permissions", kPermissions);
#endif
// create pdf_printer_settings file
prefs.SaveSettings(msg);
}
return B_OK;
}
/**
* Validate(), check that the message is built correctly for the PDF driver
Safe: does not modify the message
*
* @param BMessage*, the message to validate
* @return status_t, B_OK if the message is correctly structured
* B_ERROR if the message is corrupt
*/
status_t
PrinterSettings::Validate(const BMessage *msg)
{
int64 i64;
int32 i32;
float f;
BRect r;
BString s;
bool b;
// Test for data field existance
if (msg->FindInt64("xres", 0, &i64) != B_OK) {
return B_ERROR;
}
if (msg->FindInt64("yres", 0, &i64) != B_OK) {
return B_ERROR;
}
if (msg->FindInt32("orientation", &i32) != B_OK) {
return B_ERROR;
}
if (msg->FindRect("paper_rect", &r) != B_OK) {
return B_ERROR;
}
if (msg->FindRect("printable_rect", &r) != B_OK) {
return B_ERROR;
}
if (msg->FindFloat("scaling", &f) != B_OK) {
return B_ERROR;
}
if (msg->FindString("pdf_compatibility", &s) != B_OK) {
return B_ERROR;
}
if (msg->FindInt32("pdf_compression", &i32) != B_OK) {
return B_ERROR;
}
if (msg->FindInt32("units", &i32) != B_OK) {
return B_ERROR;
}
if (msg->FindBool("create_web_links", &b) != B_OK) {
return B_ERROR;
}
if (msg->FindFloat("link_border_width", &f) != B_OK) {
return B_ERROR;
}
if (msg->FindBool("create_bookmarks", &b) != B_OK) {
return B_ERROR;
}
if (msg->FindString("bookmark_definition_file", &s) != B_OK) {
return B_ERROR;
}
if (msg->FindBool("create_xrefs", &b) != B_OK) {
return B_ERROR;
}
if (msg->FindString("xrefs_file", &s) != B_OK) {
return B_ERROR;
}
if (msg->FindInt32("close_option", &i32) != B_OK) {
return B_ERROR;
}
#if HAVE_FULLVERSION_PDF_LIB
if (msg->FindString("pdflib_license_key", &s) != B_OK) {
return B_ERROR;
}
if (msg->FindString("user_password", &s) != B_OK) {
return B_ERROR;
}
if (msg->FindString("master_password", &s) != B_OK) {
return B_ERROR;
}
if (msg->FindString("permissions", &s) != B_OK) {
return B_ERROR;
}
#endif
// message ok
return B_OK;
}
void
PrinterSettings::Read(BNode* node, BMessage* msg, Kind kind)
{
PrinterSettings ps(*node, kind);
if (ps.Validate(msg) != B_OK) {
msg->MakeEmpty();
}
BMessage settings;
// check for previously saved settings
if (ps.ReadSettings(&settings) != B_OK || ps.Validate(&settings) != B_OK) {
// if there were none, then create a default set...
ps.GetDefaults(&settings);
}
AddFields(msg, &settings, NULL, NULL, false);
}
void
PrinterSettings::Update(BNode* node, BMessage* msg, Kind kind)
{
// Validate the message so that it is good for PDF Writer GUI
PrinterSettings ps(*node, kind);
ps.WriteSettings(msg);
}
const char*
PrinterSettings::GetAttrName() const
{
if (fKind == kJobSettings) {
return kAttrJobSettings;
} else {
return kAttrPageSettings;
}
}
@@ -1,105 +0,0 @@
/*
PrinterSettings.h
Copyright (c) 2001-2003 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef PRINTER_SETTINGS_H
#define PRINTER_SETTINGS_H
#include <StorageKit.h>
#include "PrinterDriver.h"
// Constants
const char kAttrPageSettings[] = "pdfwriter/page_settings";
const char kAttrJobSettings[] = "pdfwriter/job_settings";
// page settings
const char kPDFCompatibilty[] = "1.3";
const char kPrinterSettingsPath[] = "printers/";
const int64 kXRes = 360;
const int64 kYRes = 360;
const int32 kOrientation = PrinterDriver::PORTRAIT_ORIENTATION;
const float kRes = 72.0f;
const int32 kPDFCompression = 3;
const int32 kUnits = 1;
const float kLetterW = 8.5f * kRes;
const float kLetterH = 11.0f * kRes;
const BRect kPaperRect(0, 0, kLetterW, kLetterH);
const BRect kPrintRect(0, 0, kLetterW, kLetterH);
const bool kCreateWebLinks = false;
const float kLinkBorderWidth = 1.0;
const bool kCreateBookmarks = false;
const char kBookmarkDefinitionFile[] = "";
const bool kCreateXRefs = false;
const char kXRefsFile[] = "";
const int32 kCloseStatusWindow = 0;
// requires commercial version of PDFlib
#if HAVE_FULLVERSION_PDF_LIB
const char kPDFLibLicenseKey[] = "";
const char kUserPassword[] = ""; // none if empty
const char kMasterPassword[] = ""; // none if empty
const char kPermissions[] = ""; // all is allowed
#endif
// job settings (we do not have default values for them)
/**
* Class
*/
class PrinterSettings
{
public:
enum Kind {
kPageSettings,
kJobSettings
};
PrinterSettings(BNode &printer, Kind kind);
~PrinterSettings();
status_t InitCheck();
status_t WriteSettings(BMessage *msg);
status_t ReadSettings(BMessage *msg);
status_t GetDefaults(BMessage *msg);
status_t Validate(const BMessage *msg);
static void Read(BNode* node, BMessage* msg, Kind kind);
static void Update(BNode* node, BMessage* msg, Kind kind);
private:
PrinterSettings();
const char* GetAttrName() const;
BNode fNode;
status_t fErr;
enum Kind fKind;
};
#endif
File diff suppressed because it is too large Load Diff
@@ -1,179 +0,0 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
// This code is based on regexp.c, v.1.3 by Henry Spencer:
// @(#)regexp.c 1.3 of 18 April 87
//
// Copyright (c) 1986 by University of Toronto.
// Written by Henry Spencer. Not derived from licensed software.
//
// Permission is granted to anyone to use this software for any
// purpose on any computer system, and to redistribute it freely,
// subject to the following restrictions:
//
// 1. The author is not responsible for the consequences of use of
// this software, no matter how awful, even if they arise
// from defects in it.
//
// 2. The origin of this software must not be misrepresented, either
// by explicit claim or by omission.
//
// 3. Altered versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// Beware that some of this code is subtly aware of the way operator
// precedence is structured in regular expressions. Serious changes in
// regular-expression syntax might require a total rethink.
//
// ALTERED VERSION: Adapted to ANSI C and C++ for the OpenTracker
// project (www.opentracker.org), Jul 11, 2000.
#ifndef _REG_EXP_H
#define _REG_EXP_H
#include <String.h>
enum {
REGEXP_UNMATCHED_PARENTHESIS = B_ERRORS_END,
REGEXP_TOO_BIG,
REGEXP_TOO_MANY_PARENTHESIS,
REGEXP_JUNK_ON_END,
REGEXP_STAR_PLUS_OPERAND_EMPTY,
REGEXP_NESTED_STAR_QUESTION_PLUS,
REGEXP_INVALID_BRACKET_RANGE,
REGEXP_UNMATCHED_BRACKET,
REGEXP_INTERNAL_ERROR,
REGEXP_QUESTION_PLUS_STAR_FOLLOWS_NOTHING,
REGEXP_TRAILING_BACKSLASH,
REGEXP_CORRUPTED_PROGRAM,
REGEXP_MEMORY_CORRUPTION,
REGEXP_CORRUPTED_POINTERS,
REGEXP_CORRUPTED_OPCODE
};
const int32 kSubExpressionMax = 10;
struct regexp {
const char *startp[kSubExpressionMax];
const char *endp[kSubExpressionMax];
char regstart; /* Internal use only. See RegExp.cpp for details. */
char reganch; /* Internal use only. */
const char *regmust;/* Internal use only. */
int regmlen; /* Internal use only. */
char program[1]; /* Unwarranted chumminess with compiler. */
};
class RegExp {
public:
RegExp();
RegExp(const char *);
RegExp(const BString &);
~RegExp();
status_t InitCheck() const;
status_t SetTo(const char*);
status_t SetTo(const BString &);
bool Matches(const char *string) const;
bool Matches(const BString &) const;
int32 RunMatcher(regexp *, const char *) const;
regexp *Compile(const char *);
regexp *Expression() const;
const char *ErrorString() const;
#ifdef DEBUG
void Dump();
#endif
private:
void SetError(status_t error) const;
// Working functions for Compile():
char *Reg(int32, int32 *);
char *Branch(int32 *);
char *Piece(int32 *);
char *Atom(int32 *);
char *Node(char);
char *Next(char *);
const char *Next(const char *) const;
void Char(char);
void Insert(char, char *);
void Tail(char *, char *);
void OpTail(char *, char *);
// Working functions for RunMatcher():
int32 Try(regexp *, const char *) const;
int32 Match(const char *) const;
int32 Repeat(const char *) const;
// Utility functions:
#ifdef DEBUG
char *Prop(const char *) const;
void RegExpError(const char *) const;
#endif
inline int32 UCharAt(const char *p) const;
inline char *Operand(char* p) const;
inline const char *Operand(const char* p) const;
inline bool IsMult(char c) const;
// --------- Variables -------------
mutable status_t fError;
regexp *fRegExp;
// Work variables for Compile().
const char *fInputScanPointer;
int32 fParenthesisCount;
char fDummy;
char *fCodeEmitPointer; // &fDummy = don't.
long fCodeSize;
// Work variables for RunMatcher().
mutable const char *fStringInputPointer;
mutable const char *fRegBol; // Beginning of input, for ^ check.
mutable const char **fStartPArrayPointer;
mutable const char **fEndPArrayPointer;
};
#endif
@@ -1,102 +0,0 @@
/*
Report.
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "Report.h"
#include <string.h>
#include <Autolock.h>
#define LOGGING 0
#define LOG_TO_STDERR 0
Report* Report::fInstance = NULL;
Report::Report() {
for (int i = 0; i < kNumKinds; i++) {
fNum[i] = 0;
}
}
Report::~Report() {
}
Report* Report::Instance() {
if (fInstance == NULL) {
fInstance = new Report();
}
return fInstance;
}
void Report::Free() {
delete fInstance; fInstance = NULL;
}
void Report::Add(kind kind, int32 page, const char* fmt, ...) {
#if !LOGGING
if (kind == kDebug) return;
#endif
if (kind >= 0 && kind < kNumKinds) {
BAutolock lock(fLock);
fNum[kind] ++;
va_list list;
char *b = new char[1 << 16];
va_start(list, fmt);
#if LOG_TO_STDERR
vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
#endif
vsprintf(b, fmt, list);
AddItem(new ReportRecord(kind, page, "", b));
delete[] b;
va_end(list);
}
}
int Report::Count(kind kind) {
if (kind >= 0 && kind < kNumKinds) {
BAutolock lock(fLock);
return (int)fNum[kind];
}
return 0;
}
ReportRecord* Report::ItemAt(int32 i) {
BAutolock lock(fLock);
return inherited::ItemAt(i);
}
int32 Report::CountItems() {
BAutolock lock(fLock);
return inherited::CountItems();
}
@@ -1,94 +0,0 @@
/*
Report.
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _REPORT_H
#define _REPORT_H
#include <stdio.h>
#include <String.h>
#include <Locker.h>
#include "PrintUtils.h"
enum kind {
kInfo,
kWarning,
kError,
kDebug,
};
const int32 kNumKinds = kDebug + 1;
class ReportRecord {
public:
private:
kind fKind;
int32 fPage;
BString fLabel;
BString fDesc;
public:
ReportRecord(kind kind, int32 page, const char* label, const char* desc)
: fKind(kind), fPage(page), fLabel(label), fDesc(desc)
{ }
kind Kind() const { return fKind; }
int32 Page() const { return fPage; }
const char* Label() const { return fLabel.String(); }
const char* Desc() const { return fDesc.String(); }
};
class Report : public TList<ReportRecord>{
static Report* fInstance;
int32 fNum[kNumKinds];
BLocker fLock;
Report();
~Report();
typedef TList<ReportRecord> inherited;
public:
static Report* Instance();
void Free();
// Only these methods are "synchronized":
// Note that they are *NOT* virtual in the base class!
void Add(kind kind, int32 page, const char* fmt, ...);
int Count(kind kind);
ReportRecord* ItemAt(int32 i);
int32 CountItems();
};
#define REPORT Report::Instance()->Add
#endif
@@ -1,143 +0,0 @@
/*
Scanner.
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "Scanner.h"
#include <ctype.h>
Scanner::Scanner(const char* name) {
fFile = fopen(name, "r");
fCur.line = 1; fCur.column = 0; // line and column start at 1
fPrev.line = 1; fPrev.column = 0;
}
Scanner::~Scanner() {
if (fFile) fclose(fFile);
}
status_t Scanner::InitCheck() const {
return fFile != NULL ? B_OK : B_ERROR;
}
bool Scanner::IsEOF() const {
return feof(fFile);
}
int Scanner::GetCh() {
int ch = fgetc(fFile);
fPrev = fCur;
if (ch == '\n') {
fCur.column = 0;
fCur.line ++;
} else {
fCur.column ++;
}
return ch;
}
void Scanner::UngetCh(int ch) {
ungetc(ch, fFile);
fCur = fPrev;
}
void Scanner::SkipSpaces()
{
int c = GetCh();
for(;;) {
while (!IsEOF() && isspace(c)) c = GetCh();
if (!IsEOF() && c == '#') { // line comment; skip to end of line
while (!IsEOF() && c != '\n') c = GetCh();
} else {
UngetCh(c); return;
}
}
}
bool Scanner::ReadName(BString *s)
{
SkipSpaces();
*s = "";
int c = GetCh();
if (isalpha(c)) {
do {
s->Append((char)c, 1);
c = GetCh();
} while (!IsEOF() && isalpha(c));
UngetCh(c);
return true;
}
return false;
}
bool Scanner::ReadString(BString *s)
{
SkipSpaces();
*s = "";
int c = GetCh();
if (c == '"') {
c = GetCh();
while (!IsEOF() && c != '"') {
s->Append((char)c, 1);
c = GetCh();
}
if (c == '"') return true;
}
return false;
}
bool Scanner::ReadFloat(float *value)
{
SkipSpaces();
BString s = "";
*value = 0.0;
int c = GetCh();
if (isdigit(c) || c == '.') {
do {
s.Append((char)c, 1);
c = GetCh();
} while(isdigit(c) || c == '.');
if (EOF != sscanf(s.String(), "%f", value)) {
UngetCh(c);
return true;
}
}
return false;
}
bool Scanner::NextChar(char ch) {
SkipSpaces();
int c = GetCh();
bool match = c == ch;
if (!match) UngetCh(c);
return match;
}
@@ -1,65 +0,0 @@
/*
Scanner.
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _SCANNER_H
#define _SCANNER_H
#include <stdio.h>
#include <String.h>
class Scanner {
class Position {
public:
int32 line;
int32 column;
};
FILE* fFile;
Position fCur;
Position fPrev;
int GetCh();
void UngetCh(int ch);
public:
Scanner(const char* name);
status_t InitCheck() const;
~Scanner();
void SkipSpaces();
bool ReadName(BString* s);
bool ReadString(BString* s);
bool ReadFloat(float* f);
bool NextChar(char c);
bool IsEOF() const;
int32 Line() const { return fCur.line; }
int32 Column() const { return fCur.column; }
};
#endif
@@ -1,219 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "StatusWindow.h"
#include "Report.h"
#include <GridView.h>
#include <GroupLayout.h>
#include <GroupLayoutBuilder.h>
#include <Message.h>
static const uint32 kCancelMsg = 'cncl';
static const uint32 kProgressMsg = 'prgs';
StatusWindow::StatusWindow(int32 passes, int32 pages, PrinterDriver *pd)
:
HWindow(BRect(100, 100, 200, 200), "PDF Writer",
B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE | B_FRAME_EVENTS
| B_AUTO_UPDATE_SIZE_LIMITS,
B_CURRENT_WORKSPACE, kCancelMsg)
{
fPass = 0;
fPages = pages;
fPrinterDriver = pd;
fPageCount = 0;
fReportIndex = 0;
fCloseSem = -1;
int32 closeOption;
if (pd->JobMsg()->FindInt32("close_option", &closeOption) != B_OK)
closeOption = kNever;
fCloseOption = (CloseOption)closeOption;
fPageLabel = new BStringView("page_text", "Page");
fPageStatus = new BStatusBar("pageStatus");
fPageStatus->SetMaxValue(pages * passes);
fPageStatus->SetBarHeight(12);
fCancel = new BButton("cancel", "Cancel", new BMessage(kCancelMsg));
fReport = new BTextView("report");
fReport->SetStylable(true);
fReport->MakeEditable(false);
fReportScrollView = new BScrollView("report_scroll_viewer",
fReport, 0, false, true);
fReportScrollView->Hide();
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.AddGroup(B_HORIZONTAL)
.Add(fPageLabel)
.AddGlue()
.End()
.Add(fPageStatus)
.Add(fReportScrollView)
.AddStrut(5)
.AddGroup(B_HORIZONTAL, 10, 1.0f)
.Add(fCancel)
.End()
.SetInsets(10, 10, 10, 10)
);
Show();
}
void
StatusWindow::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case kCancelMsg:
if (fCloseSem == -1) {
fPrinterDriver->StopPrinting();
fCancel->SetEnabled(false);
} else {
fCancel->SetEnabled(false);
release_sem(fCloseSem);
}
break;
case kProgressMsg:
fPage = "";
if (fPass == 0)
fPage << "Collecting Patterns Page: " << fPageCount;
else
fPage << "Generating Page: " << fPageCount;
fPageCount ++;
if (fPageCount == fPages) {
fPass ++;
fPageCount = 0;
}
fPageLabel->SetText(fPage.String());
fPageStatus->Update(1);
UpdateReport();
break;
default:
inherited::MessageReceived(msg);
}
}
void
StatusWindow::UpdateReport()
{
Report* r = Report::Instance();
const int32 n = r->CountItems();
const bool update = fReportIndex < n;
if (update && fReportIndex == 0) {
fReportScrollView->SetExplicitMinSize(BSize(600, 400));
fReportScrollView->Show();
}
while (fReportIndex < n) {
ReportRecord* rr = r->ItemAt(fReportIndex ++);
const char* label = NULL;
rgb_color color = {0, 0, 0, 255};
switch (rr->Kind()) {
case kInfo: label = "Info"; color.green = 255; break;
case kWarning: label = "Warning"; color.red = 255; color.green=255; break;
case kError: label = "Error"; color.red = 255; break;
case kDebug: label = "Debug"; color.blue = 255; break;
}
int32 cur = fReport->TextLength()-1;
fReport->Insert(fReport->TextLength(), label, strlen(label));
int32 end = fReport->TextLength();
fReport->SetFontAndColor(cur, end, NULL, 0, &color);
char page[80];
if (rr->Page() > 0) {
sprintf(page, " (Page %d)", (int)rr->Page());
int32 len = strlen(page);
fReport->Insert(fReport->TextLength(), page, len);
}
fReport->Insert(fReport->TextLength(), ": ", 2);
fReport->Insert(fReport->TextLength(), rr->Desc(), strlen(rr->Desc()));
fReport->Insert(fReport->TextLength(), "\n", 1);
}
if (update) {
fReport->ScrollToOffset(fReport->TextLength());
fReport->Invalidate();
}
}
void
StatusWindow::NextPage()
{
PostMessage(kProgressMsg);
}
void
StatusWindow::WaitForClose()
{
fCloseSem = create_sem(0, "close_sem");
Lock();
Report* r = Report::Instance();
char b[80];
sprintf(b, "%d Infos, %d Warnings, %d Errors", r->Count(kInfo),
r->Count(kWarning), r->Count(kError));
fPageLabel->SetText(b);
fCancel->SetLabel("Close");
fCancel->SetEnabled(true);
UpdateReport();
bool hasErrors = r->Count(kError);
bool hasErrorsOrWarnings = hasErrors || r->Count(kWarning);
bool hasErrorsWarningsOrInfo = hasErrorsOrWarnings || r->Count(kInfo);
if (fCloseOption == kAlways
|| (fCloseOption == kNoErrors && !hasErrors)
|| (fCloseOption == kNoErrorsOrWarnings && !hasErrorsOrWarnings)
|| (fCloseOption == kNoErrorsWarningsOrInfo
&& !hasErrorsWarningsOrInfo)) {
PostMessage(kCancelMsg);
}
Unlock();
acquire_sem(fCloseSem);
delete_sem(fCloseSem);
}
@@ -1,71 +0,0 @@
/*
PDF Writer printer driver.
Copyright (c) 2001 OpenBeOS.
Authors:
Philippe Houdoin
Simon Gauvin
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef STATUS_WINDOW_H
#define STATUS_WINDOW_H
#include <InterfaceKit.h>
#include <SupportKit.h>
//class PrinterDriver;
#include "PrinterDriver.h"
#include "BlockingWindow.h"
#include "PrintUtils.h"
class StatusWindow : public HWindow
{
private:
int32 fPass;
int32 fPages;
BString fPage;
int32 fPageCount;
BStringView *fPageLabel;
BStatusBar *fPageStatus;
BButton *fCancel;
PrinterDriver *fPrinterDriver;
int32 fReportIndex;
BTextView* fReport;
BScrollView* fReportScrollView;
sem_id fCloseSem;
CloseOption fCloseOption;
void UpdateReport();
public:
typedef HWindow inherited;
StatusWindow(int32 passes, int32 pages, PrinterDriver *pd);
void MessageReceived(BMessage *msg);
void NextPage();
void WaitForClose();
};
#endif
@@ -1,127 +0,0 @@
/*
SubPath
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <stdio.h>
#include "SubPath.h"
SubPath::SubPath(int size)
{
fSize = size <= 0 ? kInitialSize : size;
fLength = 0;
fPoints = new BPoint[fSize];
fClosed = false;
}
SubPath::~SubPath()
{
delete []fPoints;
}
void
SubPath::MakeEmpty()
{
fLength = 0;
fClosed = false;
}
void
SubPath::Truncate(int numOfPoints)
{
fLength -= numOfPoints;
if (fLength < 0) fLength = 0;
}
void
SubPath::CheckSize(int size)
{
if (fSize < size) {
fSize = size + kIncrement;
BPoint* points = new BPoint[fSize];
for (int i = 0; i < fLength; i++) points[i] = fPoints[i];
delete []fPoints;
fPoints = points;
}
}
void
SubPath::AddPoint(BPoint p)
{
CheckSize(fLength + 1);
fPoints[fLength] = p; fLength ++;
}
void
SubPath::Close()
{
fClosed = true;
}
void
SubPath::Open()
{
fClosed = false;
}
BPoint
SubPath::PointAt(int i)
{
if (InBounds(i)) {
return fPoints[i];
}
return fPoints[0];
}
void
SubPath::AtPut(int i, BPoint p)
{
if (InBounds(i)) {
fPoints[i] = p;
}
}
void
SubPath::Print()
{
fprintf(stderr, "SubPath length = %d, size = %d ", (int)fLength, (int)fSize);
for (int i = 0; i < fLength; i++) {
if (i != 0) fprintf(stderr, ", ");
fprintf(stderr, "(%f, %f)", PointAt(i).x, PointAt(i).y);
}
fprintf(stderr, "\n");
}
@@ -1,66 +0,0 @@
/*
SubPath
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef SUBPATH_H
#define SUBPATH_H
#include <Point.h>
class SubPath {
private:
enum {
kInitialSize = 5,
kIncrement = 10
};
int32 fSize; // allocated points
int32 fLength; // number of valid points
BPoint *fPoints;
bool fClosed; // subpath connects last point with first point
void CheckSize(int size);
bool InBounds(int i) { return 0 <= i && i < fLength; }
public:
SubPath(int size = 10);
~SubPath();
void MakeEmpty();
void Truncate(int numOfPoints);
void AddPoint(BPoint p);
void Close();
void Open();
int32 CountPoints() const { return fLength; }
BPoint PointAt(int i);
void AtPut(int i, BPoint p);
bool IsClosed() const { return fClosed; }
void Print(); // for debugging
};
#endif
@@ -1,443 +0,0 @@
/*
Cross References.
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include <Debug.h>
#include <UTF8.h>
#include "Scanner.h"
#include "PDFWriter.h"
#include "XReferences.h"
#include "Report.h"
// Pattern
Pattern::Pattern(const char* pattern) {
fPattern.SetTo(pattern);
}
Pattern::~Pattern() {
}
status_t Pattern::InitCheck() {
return fPattern.InitCheck();
}
bool Pattern::Matches(const char* string, MatchResult* result) const {
regexp* re = fPattern.Expression();
result->SetRegExp(re);
result->SetString(string);
if (fPattern.RunMatcher(re, string)) {
int32 i;
for (i = 0; i < kSubExpressionMax && re->startp[i]; i++);
result->SetResults(i);
return true;
} else {
result->SetResults(0);
return false;
}
}
// MatchResult
MatchResult::MatchResult() {
fRegExp = NULL;
fString = NULL;
fResults = 0;
}
bool MatchResult::HasResult(int32 index) const {
return fRegExp && fString && index >= 0 && index < fResults;
}
const char* MatchResult::Start(int index) const {
if (HasResult(index)) {
return fRegExp->startp[index];
}
return NULL;
}
int32 MatchResult::StartPos(int index) const {
if (HasResult(index)) {
return fRegExp->startp[index] - fString;
}
return -1;
}
int32 MatchResult::EndPos(int index) const {
if (HasResult(index)) {
return fRegExp->endp[index] - fString;
}
return -1;
}
void MatchResult::GetString(int index, BString *result) {
*result = "";
if (HasResult(index)) {
const char* s = fRegExp->startp[index];
const char* e = fRegExp->endp[index];
while (s != e) { *result << *s; s++; }
}
}
// XRefDef
Pattern* XRefDef::Matches(PatternList* list, const char* s, const char** start, int32* len) {
MatchResult m;
const int32 n = list->CountItems();
Pattern* pat = NULL;
for (int32 i = 0; i < n; i++) {
Pattern* p = list->ItemAt(i);
if (p->Matches(s, &m) && m.CountResults() >= 1) {
if (m.Start(0) <= s) {
if (m.Start(0) == s && m.Length(0) <= *len) continue;
pat = p;
*start = m.Start(0);
*len = m.Length(0);
}
}
}
return pat;
}
Pattern* XRefDef::Matches(const char* s, const char** start, int32* len) {
*start = s + strlen(s); *len = 0;
Pattern* pat1 = Matches(&fLinks, s, start, len);
Pattern* pat2 = Matches(&fDests, s, start, len);
return pat2 ? pat2 : pat1;
}
// XRefDefs
void XRefDefs::Add(XRefDef* def) {
def->SetId(fDefs.CountItems());
fDefs.AddItem(def);
}
void XRefDefs::Matches(const char* s, XMatchResult* r, bool all) {
const int32 n = fDefs.CountItems();
const char* end = s + strlen(s);
MatchResult match;
do {
// match that starts at lowest position
const char* start1 = end;
XRefDef* def1 = NULL;
Pattern* pat1 = NULL;
int32 len1 = 0;
for (int32 i = 0; i < n; i ++) {
const char* start; int32 len;
XRefDef* def = fDefs.ItemAt(i);
Pattern* pat = def->Matches(s, &start, &len);
if (pat && start <= start1) {
if (start == start1 && len <= len1) continue;
start1 = start; len1 = len; pat1 = pat; def1 = def;
}
}
if (def1) {
bool found = pat1->Matches(start1, &match);
bool cont;
ASSERT(found); (void)found;
if (pat1->IsLink()) {
cont = r->MatchLink(def1, &match);
} else {
cont = r->MatchDest(def1, &match);
}
if (!cont) break;
// update for next iteration
s = start1 + len1;
} else {
if (all) {
do {
s ++;
} while (!BEGINS_CHAR(*s));
} else {
break;
}
}
} while (*s);
}
class AutoDelete {
XRefDef* fDefs;
public:
AutoDelete(XRefDef* defs) : fDefs(defs) { }
~AutoDelete() { delete fDefs; }
void Release() { fDefs = NULL; }
};
/*
FileFormat: Definition.
Line comment starts with: '#'
Definition = Version {XRefDef}.
Version = "CrossReferences" "1.0".
XRefDef = Pattern {"," Pattern} "-" ">" Pattern {"," Pattern} ".".
Pattern = '"' string '"'.
Example:
CrossReferences 1.0
"see [tT]able ([0-9]+)", "see [tT]bl. ([0-9]+)" -> "[tT]able ([0-9]+)".
"see [fF]igure ([0-9]+)" -> "[fF]igure ([0-9]+)".
"page ([0-9]+)" -> "- ([0-9]+) -"
*/
bool XRefDefs::Read(const char* name) {
Scanner scnr(name);
if (scnr.InitCheck() == B_OK) {
BString s; float f;
bool ok = scnr.ReadName(&s) && scnr.ReadFloat(&f);
if (!ok || strcmp(s.String(), "CrossReferences") != 0 || f != 1.0) {
REPORT(kError, 0, "XRefs (line %d, column %d): '%s' not a cross references file or wrong version!", scnr.Line(), scnr.Column(), name);
return false;
}
while (!scnr.IsEOF()) {
XRefDef* def = new XRefDef();
AutoDelete autoDelete(def);
BString pattern;
// Links: Pattern {"," Pattern}.
do {
if (!scnr.ReadString(&pattern)) {
REPORT(kError, 0, "XRefs (line %d, column %d): Could not parse 'link' pattern", scnr.Line(), scnr.Column());
return false;
}
LinkPattern* link = new LinkPattern(pattern.String());
if (link->InitCheck() == B_OK) {
def->AddLink(link);
} else {
delete link;
REPORT(kError, 0, "XRefs (line %d, column %d): Invalid RegExp '%s'", pattern.String(), scnr.Line(), scnr.Column());
return false;
}
} while (scnr.NextChar(','));
// "->"
if (scnr.NextChar('-') && scnr.NextChar('>')) {
// Dests: Pattern {"," Pattern}.
do {
if (!scnr.ReadString(&pattern)) {
REPORT(kError, 0, "XRefs (line %d, column %d): Could not parse 'destination' pattern", scnr.Line(), scnr.Column());
return false;
}
DestPattern* dest = new DestPattern(pattern.String());
if (dest->InitCheck() == B_OK) {
def->AddDest(dest);
} else {
delete dest;
REPORT(kError, 0, "XRefs (line %d, column %d): Invalid RegExp '%s'", scnr.Line(), scnr.Column(), pattern.String());
return false;
}
} while (scnr.NextChar(','));
// "."
if (!scnr.NextChar('.')) {
REPORT(kError, 0, "XRefs (line %d, column %d): '.' expected at end of definition", scnr.Line(), scnr.Column());
return false;
}
} else {
REPORT(kError, 0, "XRefs (line %d, column %d): '->' expected", scnr.Line(), scnr.Column());
return false;
}
this->Add(def);
autoDelete.Release();
scnr.SkipSpaces();
}
return true;
} else {
REPORT(kError, 0, "XRefs: Could not open cross references file '%d'", name);
}
return false;
}
// Destination
Destination::Destination(const char* label, int32 page, BRect bounds)
: fLabel(label)
, fPage(page)
, fBoundingBox(bounds)
{
}
// DestList
void DestList::Sort() {
// TODO: sort by label
}
Destination* DestList::Find(const char* label) {
const int n = CountItems();
// TODO: binary sort
for (int32 i = 0; i < n; i++) {
Destination* d = ItemAt(i);
if (strcmp(d->Label(), label) == 0) return d;
}
return NULL;
}
// XRefDefs
XRefDests::XRefDests(int32 n) {
fDests.MakeEmpty();
for (int32 i = 0; i < n; i ++) {
fDests.AddItem(new DestList());
}
}
bool XRefDests::Add(XRefDef* def, const char* label, int32 page, BRect boundingBox) {
DestList* list = GetList(def);
ASSERT(list != NULL);
if (!list->Find(label)) {
list->AddItem(new Destination(label, page, boundingBox));
return true;
}
return false;
}
bool XRefDests::Find(XRefDef* def, const char* label, int32* page, BRect* boundingBox) const {
DestList* list = GetList(def);
ASSERT(list != NULL);
Destination* dest = list->Find(label);
if (dest) {
*page = dest->Page();
*boundingBox = dest->BoundingBox();
return true;
}
return false;
}
// RecordDests
RecordDests::RecordDests(XRefDests* dests, TextLine* line, int32 page)
: fDests(dests)
, fLine(line)
, fPage(page)
{
}
bool RecordDests::MatchLink(XRefDef* def, MatchResult* result) {
return true;
}
bool RecordDests::MatchDest(XRefDef* def, MatchResult* result) {
if (result->CountResults() >= 2) {
BString s;
BRect b;
result->GetString(1, &s);
if (fLine->BoundingBox(result->StartPos(1), result->EndPos(1), &b)) {
fDests->Add(def, s.String(), fPage, b);
}
}
return true;
}
// LocalLink
LocalLink::LocalLink(XRefDefs* defs, XRefDests* dests, PDFWriter* writer, BString* utf8, int32 page)
: ::Link(writer, utf8)
, fDefs(defs)
, fDests(dests)
, fLinkPage(page)
{
}
bool LocalLink::MatchLink(XRefDef* def, MatchResult* result) {
if (result->CountResults() >= 2) {
BString label;
result->GetString(1, &label);
if (fDests->Find(def, label.String(), &fDestPage, &fDestBounds)) {
result->Start(1);
fContainsLink = true;
fStartPos = result->Start(1) - fUtf8->String();
const char* p = result->Start(1) + result->Length(1);
do {
p --;
} while (!BEGINS_CHAR(*p));
fEndPos = p - fUtf8->String();
return false;
} else {
REPORT(kWarning, fLinkPage, "Destination for link '%s' not found!", label.String());
}
}
return true;
}
bool LocalLink::MatchDest(XRefDef* def, MatchResult* result) {
return true;
}
void LocalLink::DetectLink(int start) {
fContainsLink = false;
fDefs->Matches(fUtf8->String() + start, this, true);
}
void LocalLink::CreateLink(float llx, float lly, float urx, float ury) {
char optList[256];
if (fDestPage != fLinkPage) {
BString s(&fUtf8->String()[fStartPos], fEndPos-fStartPos+1);
REPORT(kInfo, fLinkPage, "Link '%s' to page %d", s.String(), fDestPage);
sprintf(optList, "type=fixed left=%f top=%f", fDestBounds.left, fDestBounds.top);
PDF_add_locallink(fWriter->fPdf, llx, lly, urx, ury, fDestPage, optList);
}
}
@@ -1,239 +0,0 @@
/*
Cross References.
Copyright (c) 2002 OpenBeOS.
Author:
Michael Pfeiffer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _X_REF_H
#define _X_REF_H
#include <List.h>
#include "Link.h"
#include "RegExp.h"
#include "PrintUtils.h"
class MatchResult;
class Pattern;
// PatternList
typedef TList<Pattern> PatternList;
// Pattern
class Pattern {
protected:
RegExp fPattern;
Pattern() { };
public:
Pattern(const char* pattern);
virtual ~Pattern();
status_t InitCheck();
bool Matches(const char* string, MatchResult* result) const;
virtual bool IsLink() const { return false; }
virtual bool IsDest() const { return false; }
void Print() const;
};
// two subclasses for destinction between link and anchor
class LinkPattern : public Pattern {
public:
LinkPattern(const char* pattern) : Pattern(pattern) { }
bool IsLink() const { return true; }
};
class DestPattern : public Pattern {
public:
DestPattern(const char* pattern) : Pattern(pattern) { }
bool IsDest() const { return true; }
};
// MatchResult; wrapper for struct regexp
// NB: Pattern object must not die while MatchResult is alive
// Pattern::Matches() invalidates a previous MatchResult!
class MatchResult {
private:
regexp* fRegExp;
const char* fString;
int32 fResults;
bool HasResult(int32 index) const;
public:
MatchResult();
void SetRegExp(regexp* regexp) { fRegExp = regexp; }
void SetString(const char* string) { fString = string; }
void SetResults(int32 results) { fResults = results; }
int32 CountResults() const { return fResults; }
const char* Start(int index) const;
int32 StartPos(int index) const; // inclusive
int32 EndPos(int index) const; // exclusive
int32 Length(int index) const { return EndPos(index) - StartPos(index); }
void GetString(int index, BString *result);
};
// XRefDef
class XRefDef {
private:
PatternList fLinks;
PatternList fDests;
int fId;
Pattern* Matches(PatternList* list, const char* s, const char** start, int32 *len);
public:
XRefDef() { fId = -1; }
void SetId(int32 id) { fId = id; }
int32 Id() const { return fId; }
void AddLink(LinkPattern* p) { fLinks.AddItem(p); }
void AddDest(DestPattern* p) { fDests.AddItem(p); }
int32 CountLinks() const { return fLinks.CountItems(); }
int32 CountDests() const { return fDests.CountItems(); }
Pattern* LinkAt(int32 index) const { return fLinks.ItemAt(index); }
Pattern* DestAt(int32 index) const { return fDests.ItemAt(index); }
Pattern* Matches(const char* s, const char** start, int32 *len);
};
// XMatchResult; called from XRefDefs::Matches with matches
class XMatchResult {
public:
virtual ~XMatchResult() { };
virtual bool MatchLink(XRefDef* def, MatchResult* result) = 0;
virtual bool MatchDest(XRefDef* def, MatchResult* result) = 0;
};
// XRefDefs
class XRefDefs {
private:
TList<XRefDef> fDefs;
public:
void Add(XRefDef* def);
int32 Count() { return fDefs.CountItems(); }
// if "all" is false, only start of string is matched
void Matches(const char* s, XMatchResult* result, bool all);
bool Read(const char* name);
};
// Destination
class Destination {
private:
BString fLabel;
int32 fPage;
BRect fBoundingBox;
public:
Destination(const char* label, int32 page, BRect bounds);
const char* Label() const { return fLabel.String(); }
int32 Page() const { return fPage; }
BRect BoundingBox() const { return fBoundingBox; }
};
// DestList
class DestList : public TList<Destination> {
public:
void Sort();
Destination* Find(const char* label);
};
// XRefDests; container for the destinations
class XRefDests {
TList<DestList> fDests;
DestList* GetList(XRefDef* def) const { return fDests.ItemAt(def->Id()); }
public:
XRefDests(int32 n);
bool Add(XRefDef* def, const char* label, int32 page, BRect boundingBox);
bool Find(XRefDef* def, const char* label, int32* page, BRect* boundingBox) const;
};
// RecordDests; detect destinations and store them in XRefDests object
class RecordDests : public XMatchResult {
XRefDests* fDests;
TextLine* fLine;
int32 fPage;
public:
RecordDests(XRefDests* dests, TextLine* line, int32 page);
bool MatchLink(XRefDef* def, MatchResult* result);
bool MatchDest(XRefDef* def, MatchResult* result);
};
// LocalLink; detect links and create local links in PDF to destination
class LocalLink : public Link, XMatchResult {
protected:
XRefDefs* fDefs;
XRefDests* fDests;
int32 fLinkPage;
int32 fDestPage;
BRect fDestBounds;
void DetectLink(int start);
void CreateLink(float llx, float lly, float urx, float ury);
public:
LocalLink(XRefDefs* defs, XRefDests* dests, PDFWriter* writer, BString* utf8, int32 page);
bool MatchLink(XRefDef* def, MatchResult* result);
bool MatchDest(XRefDef* def, MatchResult* result);
};
#endif
@@ -1,11 +0,0 @@
#! /bin/sh
cd $(dirname "$0")
# remove cpu postfix
mv PDF\ Writer\ x86 PDF\ Writer
# copy driver to Print add-ons directory
cp PDF\ Writer /boot/home/config/add-ons/Print
# restart print_server
/boot/beos/system/servers/print_server
File diff suppressed because it is too large Load Diff
@@ -1,11 +0,0 @@
// WARNING: MACHINE GENERATED DON'T CHANGE!
#define UNICODE0_FROM 32
#define UNICODE0_TO 320
#define UNICODE1_FROM 321
#define UNICODE1_TO 1110
#define UNICODE2_FROM 1111
#define UNICODE2_TO 8736
#define UNICODE3_FROM 8743
#define UNICODE3_TO 63725
#define UNICODE4_FROM 63726
#define UNICODE4_TO 64331
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More