Merge lp:~lfaraone/ubuntu/lucid/xpdf/lp556483 into lp:ubuntu/lucid/xpdf

Proposed by Luke Faraone
Status: Merged
Merged at revision: not available
Proposed branch: lp:~lfaraone/ubuntu/lucid/xpdf/lp556483
Merge into: lp:ubuntu/lucid/xpdf
Diff against target: 78352 lines (+75595/-559)
111 files modified
.pc/.version (+1/-0)
.pc/01_manpage.dpatch/doc/pdffonts.1 (+142/-0)
.pc/01_manpage.dpatch/doc/pdfimages.1 (+102/-0)
.pc/01_manpage.dpatch/doc/pdfinfo.1 (+158/-0)
.pc/01_manpage.dpatch/doc/pdftoppm.1 (+119/-0)
.pc/01_manpage.dpatch/doc/pdftops.1 (+235/-0)
.pc/01_manpage.dpatch/doc/pdftotext.1 (+137/-0)
.pc/01_manpage.dpatch/doc/xpdf.1 (+863/-0)
.pc/01_manpage.dpatch/doc/xpdfrc.5 (+617/-0)
.pc/02_permissions.dpatch/xpdf/PDFCore.cc (+2044/-0)
.pc/02_permissions.dpatch/xpdf/XPDFCore.cc (+1655/-0)
.pc/02_permissions.dpatch/xpdf/XPDFViewer.cc (+3488/-0)
.pc/02_permissions.dpatch/xpdf/pdfimages.cc (+155/-0)
.pc/02_permissions.dpatch/xpdf/pdftops.cc (+344/-0)
.pc/02_permissions.dpatch/xpdf/pdftotext.cc (+333/-0)
.pc/09_xpdfrc_manpage.dpatch/doc/xpdfrc.5 (+620/-0)
.pc/80-fix-hypens-in-manpages.patch/doc/pdfinfo.1 (+157/-0)
.pc/80-fix-hypens-in-manpages.patch/doc/pdftops.1 (+234/-0)
.pc/80-fix-hypens-in-manpages.patch/doc/xpdf.1 (+874/-0)
.pc/80-fix-hypens-in-manpages.patch/doc/xpdfrc.5 (+620/-0)
.pc/applied-patches (+18/-0)
.pc/bug_408502_message_5.mbox/xpdf/XPDFViewer.cc (+3498/-0)
.pc/bug_408502_message_5.mbox/xpdf/XPDFViewer.h (+352/-0)
.pc/fix-437725.dpatch/xpdf/XPDFViewer.cc (+3492/-0)
.pc/fix-444648.dpatch/xpdf/Stream.cc (+4686/-0)
.pc/fix-462544.dpatch/xpdf/SplashOutputDev.cc (+2845/-0)
.pc/fix-479467.dpatch/xpdf/XPDFViewer.cc (+3495/-0)
.pc/fix-CVE-2007-3387_CVE-2007-5049.dpatch/xpdf/Stream.cc (+4627/-0)
.pc/fix-CVE-2007-5393_2007-5392_2007-4352.dpatch/xpdf/Stream.cc (+4625/-0)
.pc/fix-CVE-2007-5393_2007-5392_2007-4352.dpatch/xpdf/Stream.h (+858/-0)
.pc/fix-CVE-2009-0146,0147,0165,0166,0799,0800,1179-1183.dpatch/goo/gmem.cc (+264/-0)
.pc/fix-CVE-2009-0146,0147,0165,0166,0799,0800,1179-1183.dpatch/xpdf/JBIG2Stream.cc (+3413/-0)
.pc/fix-CVE-2009-3603+CVE-2009-1188.patch/splash/SplashBitmap.cc (+188/-0)
.pc/fix-CVE-2009-3604.patch/splash/Splash.cc (+3310/-0)
.pc/fix-CVE-2009-3604.patch/splash/SplashErrorCodes.h (+32/-0)
.pc/fix-CVE-2009-3606.patch/xpdf/PSOutputDev.cc (+6222/-0)
.pc/fix-CVE-2009-3608.patch/xpdf/XRef.cc (+896/-0)
.pc/fix-CVE-2009-3609.patch/xpdf/Stream.cc (+4686/-0)
.pc/xpdf-zoom-height.patch/doc/xpdf.1 (+874/-0)
.pc/xpdf-zoom-height.patch/doc/xpdfrc.5 (+620/-0)
.pc/xpdf-zoom-height.patch/xpdf/GlobalParams.cc (+2908/-0)
.pc/xpdf-zoom-height.patch/xpdf/PDFCore.cc (+2048/-0)
.pc/xpdf-zoom-height.patch/xpdf/PDFCore.h (+321/-0)
.pc/xpdf-zoom-height.patch/xpdf/XPDFCore.cc (+1663/-0)
.pc/xpdf-zoom-height.patch/xpdf/XPDFViewer.cc (+3713/-0)
.pc/xpdf-zoom-height.patch/xpdf/XPDFViewer.h (+364/-0)
.pc/xpdf-zoom-height.patch/xpdf/about-text.h (+48/-0)
debian/changelog (+76/-0)
debian/compat (+1/-1)
debian/control (+8/-7)
debian/copyright (+1/-3)
debian/patches/00list (+0/-44)
debian/patches/01_manpage.dpatch (+16/-24)
debian/patches/02_permissions.dpatch (+12/-18)
debian/patches/09_xpdfrc_manpage.dpatch (+3/-4)
debian/patches/80-fix-hypens-in-manpages.patch (+268/-0)
debian/patches/bug_408502_message_5.mbox (+327/-0)
debian/patches/bug_558020_message_5.mbox (+20/-0)
debian/patches/do-not-make-ps-arrays-bigger-than-64k-from-big-images-in-patterns.dpatch (+3/-0)
debian/patches/fix-437725.dpatch (+3/-3)
debian/patches/fix-444648.dpatch (+2/-2)
debian/patches/fix-462544.dpatch (+3/-3)
debian/patches/fix-479467.dpatch (+3/-4)
debian/patches/fix-CVE-2007-3387_CVE-2007-5049.dpatch (+3/-4)
debian/patches/fix-CVE-2007-5393_2007-5392_2007-4352.dpatch (+19/-21)
debian/patches/fix-CVE-2009-0146,0147,0165,0166,0799,0800,1179-1183.dpatch (+4/-6)
debian/patches/fix-CVE-2009-3603+CVE-2009-1188.patch (+68/-0)
debian/patches/fix-CVE-2009-3604.patch (+50/-0)
debian/patches/fix-CVE-2009-3606.patch (+13/-0)
debian/patches/fix-CVE-2009-3608.patch (+67/-0)
debian/patches/fix-CVE-2009-3609.patch (+14/-0)
debian/patches/series (+57/-0)
debian/patches/slideshow.patch.2 (+349/-0)
debian/patches/xpdf-zoom-height.patch (+253/-0)
debian/rules (+18/-23)
debian/source/format (+1/-0)
debian/watch (+2/-0)
debian/xpdf-common.postinst (+1/-1)
debian/xpdf-reader.dirs (+0/-1)
debian/xpdf-reader.files (+0/-2)
debian/xpdf-reader.menu (+1/-1)
debian/xpdf-utils.files (+2/-0)
debian/xpdf.desktop (+1/-2)
doc/pdffonts.1 (+1/-3)
doc/pdfimages.1 (+3/-5)
doc/pdfinfo.1 (+2/-3)
doc/pdftoppm.1 (+1/-3)
doc/pdftops.1 (+9/-10)
doc/pdftotext.1 (+1/-3)
doc/xpdf.1 (+53/-35)
doc/xpdfrc.5 (+12/-9)
goo/gmem.cc (+36/-4)
splash/Splash.cc (+10/-3)
splash/SplashBitmap.cc (+27/-8)
splash/SplashErrorCodes.h (+2/-0)
xpdf/GlobalParams.cc (+2/-0)
xpdf/JBIG2Stream.cc (+157/-35)
xpdf/PDFCore.cc (+28/-0)
xpdf/PDFCore.h (+4/-3)
xpdf/PSOutputDev.cc (+1/-1)
xpdf/SplashOutputDev.cc (+4/-4)
xpdf/Stream.cc (+271/-208)
xpdf/Stream.h (+6/-4)
xpdf/XPDFCore.cc (+12/-2)
xpdf/XPDFViewer.cc (+276/-39)
xpdf/XPDFViewer.h (+14/-1)
xpdf/XRef.cc (+17/-1)
xpdf/about-text.h (+1/-1)
xpdf/pdfimages.cc (+4/-0)
xpdf/pdftops.cc (+4/-0)
xpdf/pdftotext.cc (+4/-0)
To merge this branch: bzr merge lp:~lfaraone/ubuntu/lucid/xpdf/lp556483
Reviewer Review Type Date Requested Status
Ubuntu Sponsors Pending
Review via email: mp+22866@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory '.pc'
=== added file '.pc/.version'
--- .pc/.version 1970-01-01 00:00:00 +0000
+++ .pc/.version 2010-04-06 13:42:20 +0000
@@ -0,0 +1,1 @@
12
02
=== added directory '.pc/01_manpage.dpatch'
=== added directory '.pc/01_manpage.dpatch/doc'
=== added file '.pc/01_manpage.dpatch/doc/pdffonts.1'
--- .pc/01_manpage.dpatch/doc/pdffonts.1 1970-01-01 00:00:00 +0000
+++ .pc/01_manpage.dpatch/doc/pdffonts.1 2010-04-06 13:42:20 +0000
@@ -0,0 +1,142 @@
1.\" Copyright 1999-2007 Glyph & Cog, LLC
2.TH pdffonts 1 "27 February 2007"
3.SH NAME
4pdffonts \- Portable Document Format (PDF) font analyzer (version
53.02)
6.SH SYNOPSIS
7.B pdffonts
8[options]
9.RI [ PDF-file ]
10.SH DESCRIPTION
11.B Pdffonts
12lists the fonts used in a Portable Document Format (PDF) file along
13with various information for each font.
14.PP
15The following information is listed for each font:
16.TP
17.B name
18the font name, exactly as given in the PDF file (potentially including
19a subset prefix)
20.TP
21.B type
22the font type -- see below for details
23.TP
24.B emb
25"yes" if the font is embedded in the PDF file
26.TP
27.B sub
28"yes" if the font is a subset
29.TP
30.B uni
31"yes" if there is an explicit "ToUnicode" map in the PDF file (the
32absence of a ToUnicode map doesn't necessarily mean that the text
33can't be converted to Unicode)
34.TP
35.B object ID
36the font dictionary object ID (number and generation)
37.PP
38PDF files can contain the following types of fonts:
39.PP
40.RS
41Type 1
42.RE
43.RS
44Type 1C -- aka Compact Font Format (CFF)
45.RE
46.RS
47Type 1C (OT) -- OpenType with 8-bit CFF data
48.RE
49.RS
50Type 3
51.RE
52.RS
53TrueType
54.RE
55.RS
56TrueType (OT) -- OpenType with 8-bit TrueType data
57.RE
58.RS
59CID Type 0 -- 16-bit font with no specified type
60.RE
61.RS
62CID Type 0C -- 16-bit PostScript CFF font
63.RE
64.RS
65CID Type 0C (OT) -- OpenType with CID CFF data
66.RE
67.RS
68CID TrueType -- 16-bit TrueType font
69.RE
70.RS
71CID TrueType (OT) -- OpenType with CID TrueType data
72.RE
73.SH CONFIGURATION FILE
74Pdffonts reads a configuration file at startup. It first tries to
75find the user's private config file, ~/.xpdfrc. If that doesn't
76exist, it looks for a system-wide config file, typically
77/usr/local/etc/xpdfrc (but this location can be changed when pdffonts
78is built). See the
79.BR xpdfrc (5)
80man page for details.
81.SH OPTIONS
82Many of the following options can be set with configuration file
83commands. These are listed in square brackets with the description of
84the corresponding command line option.
85.TP
86.BI \-f " number"
87Specifies the first page to analyze.
88.TP
89.BI \-l " number"
90Specifies the last page to analyze.
91.TP
92.BI \-opw " password"
93Specify the owner password for the PDF file. Providing this will
94bypass all security restrictions.
95.TP
96.BI \-upw " password"
97Specify the user password for the PDF file.
98.TP
99.BI \-cfg " config-file"
100Read
101.I config-file
102in place of ~/.xpdfrc or the system-wide config file.
103.TP
104.B \-v
105Print copyright and version information.
106.TP
107.B \-h
108Print usage information.
109.RB ( \-help
110and
111.B \-\-help
112are equivalent.)
113.SH EXIT CODES
114The Xpdf tools use the following exit codes:
115.TP
1160
117No error.
118.TP
1191
120Error opening a PDF file.
121.TP
1222
123Error opening an output file.
124.TP
1253
126Error related to PDF permissions.
127.TP
12899
129Other error.
130.SH AUTHOR
131The pdffonts software and documentation are copyright 1996-2007 Glyph
132& Cog, LLC.
133.SH "SEE ALSO"
134.BR xpdf (1),
135.BR pdftops (1),
136.BR pdftotext (1),
137.BR pdfinfo (1),
138.BR pdftoppm (1),
139.BR pdfimages (1),
140.BR xpdfrc (5)
141.br
142.B http://www.foolabs.com/xpdf/
0143
=== added file '.pc/01_manpage.dpatch/doc/pdfimages.1'
--- .pc/01_manpage.dpatch/doc/pdfimages.1 1970-01-01 00:00:00 +0000
+++ .pc/01_manpage.dpatch/doc/pdfimages.1 2010-04-06 13:42:20 +0000
@@ -0,0 +1,102 @@
1.\" Copyright 1998-2007 Glyph & Cog, LLC
2.TH pdfimages 1 "27 February 2007"
3.SH NAME
4pdfimages \- Portable Document Format (PDF) image extractor
5(version 3.02)
6.SH SYNOPSIS
7.B pdfimages
8[options]
9.I PDF-file image-root
10.SH DESCRIPTION
11.B Pdfimages
12saves images from a Portable Document Format (PDF) file as Portable
13Pixmap (PPM), Portable Bitmap (PBM), or JPEG files.
14.PP
15Pdfimages reads the PDF file, scans one or more pages,
16.IR PDF-file ,
17and writes one PPM, PBM, or JPEG file for each image,
18.IR image-root - nnn . xxx ,
19where
20.I nnn
21is the image number and
22.I xxx
23is the image type (.ppm, .pbm, .jpg).
24.PP
25NB: pdfimages extracts the raw image data from the PDF file, without
26performing any additional transforms. Any rotation, clipping,
27color inversion, etc. done by the PDF content stream is ignored.
28.SH CONFIGURATION FILE
29Pdfimages reads a configuration file at startup. It first tries to
30find the user's private config file, ~/.xpdfrc. If that doesn't
31exist, it looks for a system-wide config file, typically
32/usr/local/etc/xpdfrc (but this location can be changed when pdfimages
33is built). See the
34.BR xpdfrc (5)
35man page for details.
36.SH OPTIONS
37Many of the following options can be set with configuration file
38commands. These are listed in square brackets with the description of
39the corresponding command line option.
40.TP
41.BI \-f " number"
42Specifies the first page to scan.
43.TP
44.BI \-l " number"
45Specifies the last page to scan.
46.TP
47.B \-j
48Normally, all images are written as PBM (for monochrome images) or PPM
49(for non-monochrome images) files. With this option, images in DCT
50format are saved as JPEG files. All non-DCT images are saved in
51PBM/PPM format as usual.
52.TP
53.BI \-opw " password"
54Specify the owner password for the PDF file. Providing this will
55bypass all security restrictions.
56.TP
57.BI \-upw " password"
58Specify the user password for the PDF file.
59.TP
60.B \-q
61Don't print any messages or errors.
62.RB "[config file: " errQuiet ]
63.TP
64.B \-v
65Print copyright and version information.
66.TP
67.B \-h
68Print usage information.
69.RB ( \-help
70and
71.B \-\-help
72are equivalent.)
73.SH EXIT CODES
74The Xpdf tools use the following exit codes:
75.TP
760
77No error.
78.TP
791
80Error opening a PDF file.
81.TP
822
83Error opening an output file.
84.TP
853
86Error related to PDF permissions.
87.TP
8899
89Other error.
90.SH AUTHOR
91The pdfimages software and documentation are copyright 1998-2007 Glyph
92& Cog, LLC.
93.SH "SEE ALSO"
94.BR xpdf (1),
95.BR pdftops (1),
96.BR pdftotext (1),
97.BR pdfinfo (1),
98.BR pdffonts (1),
99.BR pdftoppm (1),
100.BR xpdfrc (5)
101.br
102.B http://www.foolabs.com/xpdf/
0103
=== added file '.pc/01_manpage.dpatch/doc/pdfinfo.1'
--- .pc/01_manpage.dpatch/doc/pdfinfo.1 1970-01-01 00:00:00 +0000
+++ .pc/01_manpage.dpatch/doc/pdfinfo.1 2010-04-06 13:42:20 +0000
@@ -0,0 +1,158 @@
1.\" Copyright 1999-2007 Glyph & Cog, LLC
2.TH pdfinfo 1 "27 February 2007"
3.SH NAME
4pdfinfo \- Portable Document Format (PDF) document information
5extractor (version 3.02)
6.SH SYNOPSIS
7.B pdfinfo
8[options]
9.RI [ PDF-file ]
10.SH DESCRIPTION
11.B Pdfinfo
12prints the contents of the \'Info' dictionary (plus some other useful
13information) from a Portable Document Format (PDF) file.
14.PP
15The \'Info' dictionary contains the following values:
16.PP
17.RS
18title
19.RE
20.RS
21subject
22.RE
23.RS
24keywords
25.RE
26.RS
27author
28.RE
29.RS
30creator
31.RE
32.RS
33producer
34.RE
35.RS
36creation date
37.RE
38.RS
39modification date
40.RE
41.PP
42In addition, the following information is printed:
43.PP
44.RS
45tagged (yes/no)
46.RE
47.RS
48page count
49.RE
50.RS
51encrypted flag (yes/no)
52.RE
53.RS
54print and copy permissions (if encrypted)
55.RE
56.RS
57page size
58.RE
59.RS
60file size
61.RE
62.RS
63linearized (yes/no)
64.RE
65.RS
66PDF version
67.RE
68.RS
69metadata (only if requested)
70.RE
71.SH CONFIGURATION FILE
72Pdfinfo reads a configuration file at startup. It first tries to find
73the user's private config file, ~/.xpdfrc. If that doesn't exist, it
74looks for a system-wide config file, typically /usr/local/etc/xpdfrc
75(but this location can be changed when pdfinfo is built). See the
76.BR xpdfrc (5)
77man page for details.
78.SH OPTIONS
79Many of the following options can be set with configuration file
80commands. These are listed in square brackets with the description of
81the corresponding command line option.
82.TP
83.BI \-f " number"
84Specifies the first page to examine. If multiple pages are requested
85using the "-f" and "-l" options, the size of each requested page (and,
86optionally, the bounding boxes for each requested page) are printed.
87Otherwise, only page one is examined.
88.TP
89.BI \-l " number"
90Specifies the last page to examine.
91.TP
92.B \-box
93Prints the page box bounding boxes: MediaBox, CropBox, BleedBox,
94TrimBox, and ArtBox.
95.TP
96.B \-meta
97Prints document-level metadata. (This is the "Metadata" stream from
98the PDF file's Catalog object.)
99.TP
100.BI \-enc " encoding-name"
101Sets the encoding to use for text output. The
102.I encoding\-name
103must be defined with the unicodeMap command (see
104.BR xpdfrc (5)).
105This defaults to "Latin1" (which is a built-in encoding).
106.RB "[config file: " textEncoding ]
107.TP
108.BI \-opw " password"
109Specify the owner password for the PDF file. Providing this will
110bypass all security restrictions.
111.TP
112.BI \-upw " password"
113Specify the user password for the PDF file.
114.TP
115.BI \-cfg " config-file"
116Read
117.I config-file
118in place of ~/.xpdfrc or the system-wide config file.
119.TP
120.B \-v
121Print copyright and version information.
122.TP
123.B \-h
124Print usage information.
125.RB ( \-help
126and
127.B \-\-help
128are equivalent.)
129.SH EXIT CODES
130The Xpdf tools use the following exit codes:
131.TP
1320
133No error.
134.TP
1351
136Error opening a PDF file.
137.TP
1382
139Error opening an output file.
140.TP
1413
142Error related to PDF permissions.
143.TP
14499
145Other error.
146.SH AUTHOR
147The pdfinfo software and documentation are copyright 1996-2007 Glyph &
148Cog, LLC.
149.SH "SEE ALSO"
150.BR xpdf (1),
151.BR pdftops (1),
152.BR pdftotext (1),
153.BR pdffonts (1),
154.BR pdftoppm (1),
155.BR pdfimages (1),
156.BR xpdfrc (5)
157.br
158.B http://www.foolabs.com/xpdf/
0159
=== added file '.pc/01_manpage.dpatch/doc/pdftoppm.1'
--- .pc/01_manpage.dpatch/doc/pdftoppm.1 1970-01-01 00:00:00 +0000
+++ .pc/01_manpage.dpatch/doc/pdftoppm.1 2010-04-06 13:42:20 +0000
@@ -0,0 +1,119 @@
1.\" Copyright 2005-2007 Glyph & Cog, LLC
2.TH pdftoppm 1 "27 February 2007"
3.SH NAME
4pdftoppm \- Portable Document Format (PDF) to Portable Pixmap (PPM)
5converter (version 3.02)
6.SH SYNOPSIS
7.B pdftoppm
8[options]
9.I PDF-file PPM-root
10.SH DESCRIPTION
11.B Pdftoppm
12converts Portable Document Format (PDF) files to color image files in
13Portable Pixmap (PPM) format, grayscale image files in Portable
14Graymap (PGM) format, or monochrome image files in Portable Bitmap
15(PBM) format.
16.PP
17Pdftoppm reads the PDF file,
18.IR PDF-file ,
19and writes one PPM file for each page,
20.IR PPM-root - nnnnnn .ppm,
21where
22.I nnnnnn
23is the page number.
24.SH CONFIGURATION FILE
25Pdftoppm reads a configuration file at startup. It first tries to
26find the user's private config file, ~/.xpdfrc. If that doesn't
27exist, it looks for a system-wide config file, typically
28/usr/local/etc/xpdfrc (but this location can be changed when pdftoppm
29is built). See the
30.BR xpdfrc (5)
31man page for details.
32.SH OPTIONS
33Many of the following options can be set with configuration file
34commands. These are listed in square brackets with the description of
35the corresponding command line option.
36.TP
37.BI \-f " number"
38Specifies the first page to convert.
39.TP
40.BI \-l " number"
41Specifies the last page to convert.
42.TP
43.BI \-r " number"
44Specifies the resolution, in DPI. The default is 150 DPI.
45.TP
46.B \-mono
47Generate a monochrome PBM file (instead of a color PPM file).
48.TP
49.B \-gray
50Generate a grayscale PGM file (instead of a color PPM file).
51.TP
52.BI \-t1lib " yes | no"
53Enable or disable t1lib (a Type 1 font rasterizer). This defaults to
54"yes".
55.RB "[config file: " enableT1lib ]
56.TP
57.BI \-freetype " yes | no"
58Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
59This defaults to "yes".
60.RB "[config file: " enableFreeType ]
61.TP
62.BI \-aa " yes | no"
63Enable or disable font anti-aliasing. This defaults to "yes".
64.RB "[config file: " antialias ]
65.TP
66.BI \-aaVector " yes | no"
67Enable or disable vector anti-aliasing. This defaults to "yes".
68.RB "[config file: " vectorAntialias ]
69.TP
70.BI \-opw " password"
71Specify the owner password for the PDF file. Providing this will
72bypass all security restrictions.
73.TP
74.BI \-upw " password"
75Specify the user password for the PDF file.
76.TP
77.B \-q
78Don't print any messages or errors.
79.RB "[config file: " errQuiet ]
80.TP
81.B \-v
82Print copyright and version information.
83.TP
84.B \-h
85Print usage information.
86.RB ( \-help
87and
88.B \-\-help
89are equivalent.)
90.SH EXIT CODES
91The Xpdf tools use the following exit codes:
92.TP
930
94No error.
95.TP
961
97Error opening a PDF file.
98.TP
992
100Error opening an output file.
101.TP
1023
103Error related to PDF permissions.
104.TP
10599
106Other error.
107.SH AUTHOR
108The pdftoppm software and documentation are copyright 1996-2007 Glyph
109& Cog, LLC.
110.SH "SEE ALSO"
111.BR xpdf (1),
112.BR pdftops (1),
113.BR pdftotext (1),
114.BR pdfinfo (1),
115.BR pdffonts (1),
116.BR pdfimages (1),
117.BR xpdfrc (5)
118.br
119.B http://www.foolabs.com/xpdf/
0120
=== added file '.pc/01_manpage.dpatch/doc/pdftops.1'
--- .pc/01_manpage.dpatch/doc/pdftops.1 1970-01-01 00:00:00 +0000
+++ .pc/01_manpage.dpatch/doc/pdftops.1 2010-04-06 13:42:20 +0000
@@ -0,0 +1,235 @@
1.\" Copyright 1996-2007 Glyph & Cog, LLC
2.TH pdftops 1 "27 February 2007"
3.SH NAME
4pdftops \- Portable Document Format (PDF) to PostScript converter
5(version 3.02)
6.SH SYNOPSIS
7.B pdftops
8[options]
9.RI [ PDF-file
10.RI [ PS-file ]]
11.SH DESCRIPTION
12.B Pdftops
13converts Portable Document Format (PDF) files to PostScript so they
14can be printed.
15.PP
16Pdftops reads the PDF file,
17.IR PDF-file ,
18and writes a PostScript file,
19.IR PS-file .
20If
21.I PS-file
22is not specified, pdftops converts
23.I file.pdf
24to
25.I file.ps
26(or
27.I file.eps
28with the -eps option). If
29.I PS-file
30is \'-', the PostScript is sent to stdout.
31.SH CONFIGURATION FILE
32Pdftops reads a configuration file at startup. It first tries to find
33the user's private config file, ~/.xpdfrc. If that doesn't exist, it
34looks for a system-wide config file, typically /usr/local/etc/xpdfrc
35(but this location can be changed when pdftops is built). See the
36.BR xpdfrc (5)
37man page for details.
38.SH OPTIONS
39Many of the following options can be set with configuration file
40commands. These are listed in square brackets with the description of
41the corresponding command line option.
42.TP
43.BI \-f " number"
44Specifies the first page to print.
45.TP
46.BI \-l " number"
47Specifies the last page to print.
48.TP
49.B \-level1
50Generate Level 1 PostScript. The resulting PostScript files will be
51significantly larger (if they contain images), but will print on Level
521 printers. This also converts all images to black and white. No
53more than one of the PostScript level options (-level1, -level1sep,
54-level2, -level2sep, -level3, -level3Sep) may be given.
55.RB "[config file: " psLevel ]
56.TP
57.B \-level1sep
58Generate Level 1 separable PostScript. All colors are converted to
59CMYK. Images are written with separate stream data for the four
60components.
61.RB "[config file: " psLevel ]
62.TP
63.B \-level2
64Generate Level 2 PostScript. Level 2 supports color images and image
65compression. This is the default setting.
66.RB "[config file: " psLevel ]
67.TP
68.B \-level2sep
69Generate Level 2 separable PostScript. All colors are converted to
70CMYK. The PostScript separation convention operators are used to
71handle custom (spot) colors.
72.RB "[config file: " psLevel ]
73.TP
74.B \-level3
75Generate Level 3 PostScript. This enables all Level 2 features plus
76CID font embedding and masked image generation.
77.RB "[config file: " psLevel ]
78.TP
79.B \-level3Sep
80Generate Level 3 separable PostScript. The separation handling is the
81same as for -level2Sep.
82.RB "[config file: " psLevel ]
83.TP
84.B \-eps
85Generate an Encapsulated PostScript (EPS) file. An EPS file contains
86a single image, so if you use this option with a multi-page PDF file,
87you must use -f and -l to specify a single page. No more than one of
88the mode options (-eps, -form) may be given.
89.TP
90.B \-form
91Generate a PostScript form which can be imported by software that
92understands forms. A form contains a single page, so if you use this
93option with a multi-page PDF file, you must use -f and -l to specify a
94single page. The -level1 option cannot be used with -form.
95.TP
96.B \-opi
97Generate OPI comments for all images and forms which have OPI
98information. (This option is only available if pdftops was compiled
99with OPI support.)
100.RB "[config file: " psOPI ]
101.TP
102.B \-noembt1
103By default, any Type 1 fonts which are embedded in the PDF file are
104copied into the PostScript file. This option causes pdftops to
105substitute base fonts instead. Embedded fonts make PostScript files
106larger, but may be necessary for readable output.
107.RB "[config file: " psEmbedType1Fonts ]
108.TP
109.B \-noembtt
110By default, any TrueType fonts which are embedded in the PDF file are
111copied into the PostScript file. This option causes pdftops to
112substitute base fonts instead. Embedded fonts make PostScript files
113larger, but may be necessary for readable output. Also, some
114PostScript interpreters do not have TrueType rasterizers.
115.RB "[config file: " psEmbedTrueTypeFonts ]
116.TP
117.B \-noembcidps
118By default, any CID PostScript fonts which are embedded in the PDF
119file are copied into the PostScript file. This option disables that
120embedding. No attempt is made to substitute for non-embedded CID
121PostScript fonts.
122.RB "[config file: " psEmbedCIDPostScriptFonts ]
123.TP
124.B \-noembcidtt
125By default, any CID TrueType fonts which are embedded in the PDF file
126are copied into the PostScript file. This option disables that
127embedding. No attempt is made to substitute for non-embedded CID
128TrueType fonts.
129.RB "[config file: " psEmbedCIDTrueTypeFonts ]
130.TP
131.B \-preload
132Convert PDF forms to PS procedures, and preload image data. This uses
133more memory in the PostScript interpreter, but generates significantly
134smaller PS files in situations where, e.g., the same image is drawn on
135every page of a long document.
136.TP
137.BI \-paper " size"
138Set the paper size to one of "letter", "legal", "A4", or "A3". This
139can also be set to "match", which will set the paper size to match the
140size specified in the PDF file.
141.RB "[config file: " psPaperSize ]
142.TP
143.BI \-paperw " size"
144Set the paper width, in points.
145.RB "[config file: " psPaperSize ]
146.TP
147.BI \-paperh " size"
148Set the paper height, in points.
149.RB "[config file: " psPaperSize ]
150.TP
151.B \-nocrop
152By default, output is cropped to the CropBox specified in the PDF
153file. This option disables cropping.
154.RB "[config file: " psCrop ]
155.TP
156.B \-expand
157Expand PDF pages smaller than the paper to fill the paper. By
158default, these pages are not scaled.
159.RB "[config file: " psExpandSmaller ]
160.TP
161.B \-noshrink
162Don't scale PDF pages which are larger than the paper. By default,
163pages larger than the paper are shrunk to fit.
164.RB "[config file: " psShrinkLarger ]
165.TP
166.B \-nocenter
167By default, PDF pages smaller than the paper (after any scaling) are
168centered on the paper. This option causes them to be aligned to the
169lower-left corner of the paper instead.
170.RB "[config file: " psCenter ]
171.TP
172.B \-pagecrop
173Treat the CropBox as the PDF page size. By default, the MediaBox is
174used as the page size.
175.TP
176.B \-duplex
177Set the Duplex pagedevice entry in the PostScript file. This tells
178duplex-capable printers to enable duplexing.
179.RB "[config file: " psDuplex ]
180.TP
181.BI \-opw " password"
182Specify the owner password for the PDF file. Providing this will
183bypass all security restrictions.
184.TP
185.BI \-upw " password"
186Specify the user password for the PDF file.
187.TP
188.B \-q
189Don't print any messages or errors.
190.RB "[config file: " errQuiet ]
191.TP
192.BI \-cfg " config-file"
193Read
194.I config-file
195in place of ~/.xpdfrc or the system-wide config file.
196.TP
197.B \-v
198Print copyright and version information.
199.TP
200.B \-h
201Print usage information.
202.RB ( \-help
203and
204.B \-\-help
205are equivalent.)
206.SH EXIT CODES
207The Xpdf tools use the following exit codes:
208.TP
2090
210No error.
211.TP
2121
213Error opening a PDF file.
214.TP
2152
216Error opening an output file.
217.TP
2183
219Error related to PDF permissions.
220.TP
22199
222Other error.
223.SH AUTHOR
224The pdftops software and documentation are copyright 1996-2007 Glyph &
225Cog, LLC.
226.SH "SEE ALSO"
227.BR xpdf (1),
228.BR pdftotext (1),
229.BR pdfinfo (1),
230.BR pdffonts (1),
231.BR pdftoppm (1),
232.BR pdfimages (1),
233.BR xpdfrc (5)
234.br
235.B http://www.foolabs.com/xpdf/
0236
=== added file '.pc/01_manpage.dpatch/doc/pdftotext.1'
--- .pc/01_manpage.dpatch/doc/pdftotext.1 1970-01-01 00:00:00 +0000
+++ .pc/01_manpage.dpatch/doc/pdftotext.1 2010-04-06 13:42:20 +0000
@@ -0,0 +1,137 @@
1.\" Copyright 1997-2007 Glyph & Cog, LLC
2.TH pdftotext 1 "27 Febuary 2007"
3.SH NAME
4pdftotext \- Portable Document Format (PDF) to text converter
5(version 3.02)
6.SH SYNOPSIS
7.B pdftotext
8[options]
9.RI [ PDF-file
10.RI [ text-file ]]
11.SH DESCRIPTION
12.B Pdftotext
13converts Portable Document Format (PDF) files to plain text.
14.PP
15Pdftotext reads the PDF file,
16.IR PDF-file ,
17and writes a text file,
18.IR text-file .
19If
20.I text-file
21is not specified, pdftotext converts
22.I file.pdf
23to
24.IR file.txt .
25If
26.I text-file
27is \'-', the text is sent to stdout.
28.SH CONFIGURATION FILE
29Pdftotext reads a configuration file at startup. It first tries to
30find the user's private config file, ~/.xpdfrc. If that doesn't
31exist, it looks for a system-wide config file, typically
32/usr/local/etc/xpdfrc (but this location can be changed when pdftotext
33is built). See the
34.BR xpdfrc (5)
35man page for details.
36.SH OPTIONS
37Many of the following options can be set with configuration file
38commands. These are listed in square brackets with the description of
39the corresponding command line option.
40.TP
41.BI \-f " number"
42Specifies the first page to convert.
43.TP
44.BI \-l " number"
45Specifies the last page to convert.
46.TP
47.B \-layout
48Maintain (as best as possible) the original physical layout of the
49text. The default is to \'undo' physical layout (columns,
50hyphenation, etc.) and output the text in reading order.
51.TP
52.B \-raw
53Keep the text in content stream order. This is a hack which often
54"undoes" column formatting, etc. Use of raw mode is no longer
55recommended.
56.TP
57.B \-htmlmeta
58Generate a simple HTML file, including the meta information. This
59simply wraps the text in <pre> and </pre> and prepends the meta
60headers.
61.TP
62.BI \-enc " encoding-name"
63Sets the encoding to use for text output. The
64.I encoding\-name
65must be defined with the unicodeMap command (see
66.BR xpdfrc (5)).
67The encoding name is case-sensitive. This defaults to "Latin1" (which
68is a built-in encoding).
69.RB "[config file: " textEncoding ]
70.TP
71.BI \-eol " unix | dos | mac"
72Sets the end-of-line convention to use for text output.
73.RB "[config file: " textEOL ]
74.TP
75.B \-nopgbrk
76Don't insert page breaks (form feed characters) between pages.
77.RB "[config file: " textPageBreaks ]
78.TP
79.BI \-opw " password"
80Specify the owner password for the PDF file. Providing this will
81bypass all security restrictions.
82.TP
83.BI \-upw " password"
84Specify the user password for the PDF file.
85.TP
86.B \-q
87Don't print any messages or errors.
88.RB "[config file: " errQuiet ]
89.TP
90.BI \-cfg " config-file"
91Read
92.I config-file
93in place of ~/.xpdfrc or the system-wide config file.
94.TP
95.B \-v
96Print copyright and version information.
97.TP
98.B \-h
99Print usage information.
100.RB ( \-help
101and
102.B \-\-help
103are equivalent.)
104.SH BUGS
105Some PDF files contain fonts whose encodings have been mangled beyond
106recognition. There is no way (short of OCR) to extract text from
107these files.
108.SH EXIT CODES
109The Xpdf tools use the following exit codes:
110.TP
1110
112No error.
113.TP
1141
115Error opening a PDF file.
116.TP
1172
118Error opening an output file.
119.TP
1203
121Error related to PDF permissions.
122.TP
12399
124Other error.
125.SH AUTHOR
126The pdftotext software and documentation are copyright 1996-2007 Glyph
127& Cog, LLC.
128.SH "SEE ALSO"
129.BR xpdf (1),
130.BR pdftops (1),
131.BR pdfinfo (1),
132.BR pdffonts (1),
133.BR pdftoppm (1),
134.BR pdfimages (1),
135.BR xpdfrc (5)
136.br
137.B http://www.foolabs.com/xpdf/
0138
=== added file '.pc/01_manpage.dpatch/doc/xpdf.1'
--- .pc/01_manpage.dpatch/doc/xpdf.1 1970-01-01 00:00:00 +0000
+++ .pc/01_manpage.dpatch/doc/xpdf.1 2010-04-06 13:42:20 +0000
@@ -0,0 +1,863 @@
1.\" Copyright 1996-2007 Glyph & Cog, LLC
2.TH xpdf 1 "27 February 2007"
3.SH NAME
4xpdf \- Portable Document Format (PDF) file viewer for X (version 3.02)
5.SH SYNOPSIS
6.B xpdf
7[options]
8.RI [ PDF-file
9.RI [ page " | +" dest ]]
10.SH DESCRIPTION
11.B Xpdf
12is a viewer for Portable Document Format (PDF) files. (These are also
13sometimes also called \'Acrobat' files, from the name of Adobe's PDF
14software.) Xpdf runs under the X Window System on UNIX, VMS, and
15OS/2.
16.PP
17To run xpdf, simply type:
18.PP
19.RS
20xpdf file.pdf
21.RE
22.PP
23where
24.I file.pdf
25is your PDF file. The file name can be followed by a number
26specifying the page which should be displayed first, e.g.:
27.PP
28.RS
29xpdf file.pdf 18
30.RE
31.PP
32You can also give a named destination, prefixed with \'+' in place of
33the page number. (This is only useful with PDF files that provide
34named destination targets.)
35.PP
36You can also start xpdf without opening any files:
37.PP
38.RS
39xpdf
40.RE
41.SH CONFIGURATION FILE
42Xpdf reads a configuration file at startup. It first tries to find
43the user's private config file, ~/.xpdfrc. If that doesn't exist, it
44looks for a system-wide config file, typically /usr/local/etc/xpdfrc
45(but this location can be changed when xpdf is built). See the
46.BR xpdfrc (5)
47man page for details.
48.SH OPTIONS
49Many of the following options can be set with configuration file
50commands or X resources. These are listed in square brackets with the
51description of the corresponding command line option.
52.TP
53.BI \-g " geometry"
54Set the initial window geometry.
55.RB ( \-geometry
56is equivalent.)
57.RB "[X resource: " xpdf.geometry ]
58.TP
59.BI \-title " title"
60Set the window title. By default, the title will be "xpdf: foo.pdf".
61.RB "[X resource: " xpdf.title ]
62.TP
63.B \-cmap
64Install a private colormap. This is ignored on TrueColor visuals.
65.RB "[X resource: " xpdf.installCmap ]
66.TP
67.BI \-rgb " number"
68Set the size of largest RGB cube xpdf will try to allocate. The
69default is 5 (for a 5x5x5 cube); set to a smaller number to conserve
70color table entries. This is ignored with private colormaps and on
71TrueColor visuals.
72.RB "[X resource: " xpdf.rgbCubeSize ]
73.TP
74.B \-rv
75Set reverse video mode. This reverses the colors of everything except
76images. It may not always produce great results for PDF files which
77do weird things with color. This also causes the paper color to
78default to black.
79.RB "[X resource: " xpdf.reverseVideo ]
80.TP
81.BI \-papercolor " color"
82Set the "paper color", i.e., the background of the page display. This
83will not work too well with PDF files that do things like filling in
84white behind the text.
85.RB "[X resource: " xpdf.paperColor ]
86.TP
87.BI \-mattecolor " color"
88Set the matte color, i.e., the color used for background outside the
89actual page area. (There is a separate setting,
90xpdf.fullScreenMatteColor, for full-screen mode.)
91.RB "[X resource: " xpdf.matteColor ]
92.TP
93.BI \-z " zoom"
94Set the initial zoom factor. A number specifies a zoom percentage,
95where 100 means 72 dpi.You may also specify \'page', to fit the page
96to the window size, or \'width', to fit the page width to the window
97width.
98.RB "[config file: " initialZoom "; or X resource: " xpdf.initialZoom ]
99.TP
100.B \-cont
101Start in continuous view mode, i.e., with one vertical scroll bar for
102the whole document.
103.RB "[config file: " continuousView ]
104.TP
105.BI \-t1lib " yes | no"
106Enable or disable t1lib (a Type 1 font rasterizer). This defaults to
107"yes".
108.RB "[config file: " enableT1lib ]
109.TP
110.BI \-freetype " yes | no"
111Enable or disable FreeType (a TrueType / Type 1 font rasterizer).
112This defaults to "yes".
113.RB "[config file: " enableFreeType ]
114.TP
115.BI \-aa " yes | no"
116Enable or disable font anti-aliasing. This defaults to "yes".
117.RB "[config file: " antialias ]
118.TP
119.BI \-aaVector " yes | no"
120Enable or disable vector anti-aliasing. This defaults to "yes".
121.RB "[config file: " vectorAntialias ]
122.TP
123.BI \-ps " PS-file"
124Set the default file name for PostScript output (i.e., the name which
125will appear in the print dialog). This can also be of the form
126\'|command' to pipe the PostScript through a command.
127.RB "[config file: " psFile ]
128.TP
129.BI \-paper " size"
130Set the paper size to one of "letter", "legal", "A4", or "A3". This
131can also be set to "match", which will set the paper size to match the
132size specified in the PDF file.
133.RB "[config file: " psPaperSize ]
134.TP
135.BI \-paperw " size"
136Set the paper width, in points.
137.RB "[config file: " psPaperSize ]
138.TP
139.BI \-paperh " size"
140Set the paper height, in points.
141.RB "[config file: " psPaperSize ]
142.TP
143.B \-level1
144Generate Level 1 PostScript. The resulting PostScript files will be
145significantly larger (if they contain images), but will print on Level
1461 printers. This also converts all images to black and white.
147.RB "[config file: " psLevel ]
148.TP
149.BI \-enc " encoding-name"
150Sets the encoding to use for text output. The
151.I encoding\-name
152must be defined with the unicodeMap command (see
153.BR xpdfrc (5)).
154This defaults to "Latin1" (which is a built-in encoding).
155.RB "[config file: " textEncoding ]
156.TP
157.BI \-eol " unix | dos | mac"
158Sets the end-of-line convention to use for text output.
159.RB "[config file: " textEOL ]
160.TP
161.BI \-opw " password"
162Specify the owner password for the PDF file. Providing this will
163bypass all security restrictions.
164.TP
165.BI \-upw " password"
166Specify the user password for the PDF file.
167.TP
168.B \-fullscreen
169Open xpdf in full-screen mode, useful for presentations.
170.TP
171.BI \-remote " name"
172Start/contact xpdf remote server with specified name (see the
173.B "REMOTE SERVER MODE"
174section below).
175.TP
176.BI \-exec " command"
177Execute a command (see the
178.B COMMANDS
179section below) in an xpdf remote server window (with -remote only).
180.TP
181.B \-reload
182Reload xpdf remote server window (with -remote only).
183.TP
184.B \-raise
185Raise xpdf remote server window (with -remote only).
186.TP
187.B \-quit
188Kill xpdf remote server (with -remote only).
189.TP
190.B \-cmd
191Print commands as they're executed (useful for debugging).
192.RB "[config file: " printCommands ]
193.TP
194.B \-q
195Don't print any messages or errors.
196.RB "[config file: " errQuiet ]
197.TP
198.BI \-cfg " config-file"
199Read
200.I config-file
201in place of ~/.xpdfrc or the system-wide config file.
202.TP
203.B \-v
204Print copyright and version information.
205.TP
206.B \-h
207Print usage information.
208.RB ( \-help
209and
210.B \-\-help
211are equivalent.)
212.PP
213Several other standard X options and resources will work as expected:
214.TP
215.BI \-display " display"
216.RB "[X resource: " xpdf.display ]
217.TP
218.BI \-fg " color"
219.RB ( \-foreground
220is equivalent.)
221.RB "[X resource: " xpdf*Foreground ]
222.TP
223.BI \-bg " color"
224.RB ( \-background
225is equivalent.)
226.RB "[X resource: " xpdf*Background ]
227.TP
228.BI \-font " font"
229.RB ( \-fn
230is equivalent.)
231.RB "[X resource: " xpdf*fontList ]
232.PP
233The color and font options only affect the user interface elements,
234not the PDF display (the \'paper').
235.PP
236The following X resources do not have command line option equivalents:
237.TP
238.B xpdf.toolTipEnable
239Enables (if set to true) or disables (if set to false) the tool-tips
240on the toolbar buttons.
241.TP
242.B xpdf.fullScreenMatteColor
243Sets the matte color to be used in full-screen mode. The default
244setting is "black".
245.SH CONTROLS
246.SS On-screen controls, at the bottom of the xpdf window
247.TP
248.B "left/right arrow buttons"
249Move to the previous/next page.
250.TP
251.B "double left/right arrow buttons"
252Move backward or forward by ten pages.
253.TP
254.B "dashed left/right arrow buttons"
255Move backward or forward along the history path.
256.TP
257.B "\'Page' entry box"
258Move to a specific page number. Click in the box to activate it, type
259the page number, then hit return.
260.TP
261.B "zoom popup menu"
262Change the zoom factor (see the description of the -z option above).
263.TP
264.B "binoculars button"
265Find a text string.
266.TP
267.B "print button"
268Bring up a dialog for generating a PostScript file. The dialog has
269options to set the pages to be printed and the PostScript file name.
270The file name can be \'-' for stdout or \'|command' to pipe the
271PostScript through a command, e.g., \'|lpr'.
272.TP
273.B "\'?' button"
274Bring up the \'about xpdf' window.
275.TP
276.B "link info"
277The space between the \'?' and \'Quit' buttons is used to show the URL
278or external file name when the mouse is over a link.
279.TP
280.B "\'Quit' button"
281Quit xpdf.
282.PP
283.SS Menu
284Pressing the right mouse button will post a popup menu with the
285following commands:
286.TP
287.B "Open..."
288Open a new PDF file via a file requester.
289.TP
290.B "Open in new window..."
291Create a new window and open a new PDF file via a file requester.
292.TP
293.B "Reload"
294Reload the current PDF file. Note that Xpdf will reload the file
295automatically (on a page change or redraw) if it has changed since it
296was last loaded.
297.TP
298.B "Save as..."
299Save the current file via a file requester.
300.TP
301.B "Continuous view"
302Toggles between single page and continuous view modes.
303.TP
304.B "Rotate counterclockwise"
305Rotate the page 90 degrees counterclockwise.
306.TP
307.B "Rotate clockwise"
308Rotate the page 90 degrees clockwise. The two rotate commands are
309intended primarily for PDF files where the rotation isn't correctly
310specified in the file.
311.TP
312.B "Zoom to selection"
313Zoom in to the currently selected rectangle.
314.TP
315.B "Close"
316Close the current window. If this is the only open window, the
317document is closed, but the window is left open (i.e., this menu
318command won't quit xpdf).
319.TP
320.B "Quit"
321Quit xpdf.
322.PP
323.SS Outline
324If the PDF contains an outline (a.k.a., bookmarks), there will be an
325outline pane on the left side of the window. The width of the outline
326pane is adjustable with a vertical split bar via the knob near its
327bottom end.
328.PP
329.SS Text selection
330Dragging the mouse with the left button held down will highlight an
331arbitrary rectangle. Any text inside this rectangle will be copied to
332the X selection buffer.
333.PP
334.SS Links
335Clicking on a hyperlink will jump to the link's destination. A link
336to another PDF document will make xpdf load that document. A
337\'launch' link to an executable program will display a dialog, and if
338you click \'ok', execute the program. URL links call an external
339command (see the
340.B WEB BROWSERS
341section below).
342.PP
343.SS Panning
344Dragging the mouse with the middle button held down pans the window.
345.PP
346.SS Key bindings
347.TP
348.B o
349Open a new PDF file via a file requester.
350.TP
351.B r
352Reload the current PDF file. Note that Xpdf will reload the file
353automatically (on a page change or redraw) if it has changed since it
354was last loaded.
355.TP
356.B control-L
357Redraw the current page.
358.TP
359.B control-W
360Close the current window.
361.TP
362.B f or control-F
363Find a text string.
364.TP
365.B control-G
366Find next occurrence.
367.TP
368.B control-P
369Print.
370.TP
371.B n
372Move to the next page. Scrolls to the top of the page, unless scroll
373lock is turned on.
374.TP
375.B p
376Move to the previous page. Scrolls to the top of the page, unless
377scroll lock is turned on.
378.TP
379.BR <Space> " or " <PageDown> " or " <Next>
380Scroll down on the current page; if already at bottom, move to next
381page.
382.TP
383.BR <Backspace> " or " <Delete> " or " <PageUp> " or " <Previous>
384Scroll up on the current page; if already at top, move to previous
385page.
386.TP
387.B v
388Move forward along the history path.
389.TP
390.B b
391Move backward along the history path.
392.TP
393.B <Home>
394Scroll to top of current page.
395.TP
396.B <End>
397Scroll to bottom of current page.
398.TP
399.B control-<Home>
400Scroll to first page of document.
401.TP
402.B control-<End>
403Scroll to last page of document.
404.TP
405.B arrows
406Scroll the current page.
407.TP
408.B g
409Activate the page number text field ("goto page").
410.TP
411.B 0
412Set the zoom factor to 125%.
413.TP
414.B +
415Zoom in (increment the zoom factor by 1).
416.TP
417.B -
418Zoom out (decrement the zoom factor by 1).
419.TP
420.B z
421Set the zoom factor to 'page' (fit page to window).
422.TP
423.B w
424Set the zoom factor to 'width' (fit page width to window).
425.TP
426.B alt-F
427Toggle full-screen mode.
428.TP
429.B q
430Quit xpdf.
431.SH "WEB BROWSERS"
432If you want to run xpdf automatically from netscape or mosaic (and
433probably other browsers) when you click on a link to a PDF file, you
434need to edit (or create) the files
435.I .mime.types
436and
437.I .mailcap
438in your home directory. In
439.I .mime.types
440add the line:
441.PP
442.RS
443application/pdf pdf
444.RE
445.PP
446In
447.I .mailcap
448add the lines:
449.PP
450.RS
451# Use xpdf to view PDF files.
452.RE
453.RS
454application/pdf; xpdf -q %s
455.RE
456.PP
457Make sure that xpdf is on your executable search path.
458.PP
459When you click on a URL link in a PDF file, xpdf will execute the
460command specified by the urlCommand config file option, replacing an
461occurrence of \'%s' with the URL. For example, to call netscape with
462the URL, add this line to your config file:
463.PP
464.RS
465urlCommand "netscape -remote 'openURL(%s)'"
466.RE
467.SH COMMANDS
468Xpdf's key and mouse bindings are user-configurable, using the bind and
469unbind options in the config file (see
470.BR xpdfrc (5)).
471The bind command allows you to bind a key or mouse button to a
472sequence of one or more commands.
473.SS Available Commands
474The following commands are supported:
475.TP
476.BI gotoPage( page )
477Go to the specified page.
478.TP
479.BI gotoPageNoScroll( page )
480Go to the specified page, with the current relative scroll position.
481.TP
482.BI gotoDest( dest )
483Go to a named destination.
484.TP
485.B gotoLastPage
486Go to the last page in the PDF file.
487.TP
488.B gotoLastPageNoScroll
489Go to the last page in the PDF file, with the current relative scroll
490position.
491.TP
492.B nextPage
493Go to the next page.
494.TP
495.B nextPageNoScroll
496Go to the next page, with the current relative scroll position.
497.TP
498.B prevPage
499Go to the previous page.
500.TP
501.B prevPageNoScroll
502Go to the previous page, with the current relative scroll position.
503.TP
504.B pageUp
505Scroll up by one screenful.
506.TP
507.B pageDown
508Scroll down by one screenful.
509.TP
510.BI scrollLeft( n )
511Scroll left by
512.I n
513pixels.
514.TP
515.BI scrollRight( n )
516Scroll right by
517.I n
518pixels.
519.TP
520.BI scrollUp( n )
521Scroll up by
522.I n
523pixels.
524.TP
525.BI scrollDown( n )
526Scroll down by
527.I n
528pixels.
529.TP
530.BI scrollUpPrevPage( n )
531Scroll up by
532.I n
533pixels, moving to the previous page if appropriate.
534.TP
535.BI scrollDownPrevPage( n )
536Scroll down by
537.I n
538pixels, moving to the next page if appropriate.
539.TP
540.B scrollToTopEdge
541Scroll to the top edge of the current page, with no horizontal
542movement.
543.TP
544.B scrollToBottomEdge
545Scroll to the bottom edge of the current page, with no horizontal
546movement.
547.TP
548.B scrollToLeftEdge
549Scroll to the left edge of the current page, with no vertical
550movement.
551.TP
552.B scrollToRightEdge
553Scroll to the right edge of the current page, with no vertical
554movement.
555.TP
556.B scrollToTopLeft
557Scroll to the top-left corner of the current page.
558.TP
559.B scrollToBottomRight
560Scroll to the bottom-right corner of the current page.
561.TP
562.B goForward
563Move forward along the history path.
564.TP
565.B goBackward
566Move backward along the history path.
567.TP
568.BI zoomPercent( z )
569Set the zoom factor to
570.IR z %.
571.TP
572.B zoomFitPage
573Set the zoom factor to fit-page.
574.TP
575.B zoomFitWidth
576Set the zoom factor to fit-width.
577.TP
578.B zoomIn
579Zoom in - go to the next higher zoom factor.
580.TP
581.B zoomOut
582Zoom out - go the next lower zoom factor.
583.TP
584.B continuousMode
585Go to continuous view mode.
586.TP
587.B singlePageMode
588Go to single-page view mode.
589.TP
590.B toggleContinuousMode
591Toggle between continuous and single page view modes.
592.TP
593.B fullScreenMode
594Go to full-screen mode.
595.TP
596.B windowMode
597Go to window (non-full-screen) mode.
598.TP
599.B toggleFullScreenMode
600Toggle between full-screen and window modes.
601.TP
602.B open
603Open a PDF file in this window, using the open dialog.
604.TP
605.B openInNewWin
606Open a PDF file in a new window, using the open dialog.
607.TP
608.BI openFile( file )
609Open a specified PDF file in this window.
610.TP
611.BI openFileInNewWin( file )
612Open a specified PDF file in a new window.
613.TP
614.BI openFileAtDest( file , dest )
615Open a specified PDF file in this window and go to a named
616destination.
617.TP
618.BI openFileAtDestInNewWin( file , dest )
619Open a specified PDF file in a new window and go to a named
620destination.
621.TP
622.B reload
623Reload the current PDF file.
624.TP
625.B redraw
626Redraw the window.
627.TP
628.B raise
629Raise the window to the front.
630.TP
631.B closeWindow
632Close the window.
633.TP
634.BI run( external-command-string )
635Run an external command. The following escapes are allowed in the
636command string:
637.nf
638
639 %f => PDF file name (or an empty string if no
640 file is open)
641 %b => PDF file base name, i.e., file name minus
642 the extension (or an empty string if no
643 file is open)
644 %u => link URL (or an empty string if not over
645 a URL link)
646 %x => selection upper-left x coordinate
647 (or 0 if there is no selection)
648 %y => selection upper-left y coordinate
649 (or 0 if there is no selection)
650 %X => selection lower-right x coordinate
651 (or 0 if there is no selection)
652 %Y => selection lower-right y coordinate
653 (or 0 if there is no selection)
654 %% => %
655
656.fi
657.TP
658.B openOutline
659Open the outline pane.
660.TP
661.B closeOutline
662Close the outline pane.
663.TP
664.B toggleOutline
665Toggle the outline pane between open and closed.
666.TP
667.BI scrollOutlineDown( n )
668Scroll the outline down by
669.I n
670increments.
671.TP
672.BI scrollOutlineUp( n )
673Scroll the outline up by
674.I n
675increments.
676.TP
677.B focusToDocWin
678Set the keyboard focus to the main document window.
679.TP
680.B focusToPageNum
681Set the keyboard focus to the page number text box.
682.TP
683.B find
684Open the 'find' dialog.
685.TP
686.B findNext
687Finds the next occurrence of the search string (no dialog).
688.TP
689.B print
690Open the 'print' dialog.
691.TP
692.B about
693Open the 'about' dialog.
694.TP
695.B quit
696Quit from xpdf.
697.PP
698The following commands depend on the current mouse position:
699.TP
700.B startSelection
701Start a selection, which will be extended as the mouse moves.
702.TP
703.B endSelection
704End a selection.
705.TP
706.B startPan
707Start a pan, which will scroll the document as the mouse moves
708.TP
709.B endPan
710End a pan.
711.TP
712.B postPopupMenu
713Display the popup menu.
714.TP
715.B followLink
716Follow a hyperlink (does nothing if the mouse is not over a link).
717.TP
718.B followLinkInNewWin
719Follow a hyperlink, opening PDF files in a new window (does nothing if
720the mouse is not over a link). For links to non-PDF files, this
721command is identical to followLink.
722.TP
723.B followLinkNoSel
724Same as followLink, but does nothing if there is a non-empty selection.
725(This is useful as a mouse button binding.)
726.TP
727.B followLinkInNewWinNoSel
728Same as followLinkInNewWin, but does nothing if there is a non-empty
729selection. (This is useful as a mouse button binding.)
730.SS Default Bindings
731The default mouse bindings are as follows:
732.nf
733
734 bind mousePress1 any startSelection
735 bind mouseRelease1 any endSelection followLinkNoSel
736 bind mousePress2 any startPan
737 bind mouseRelease2 any endPan
738 bind mousePress3 any postPopupMenu
739 bind mousePress4 any scrollUpPrevPage(16)
740 bind mousePress5 any scrollDownNextPage(16)
741 bind mousePress6 any scrollLeft(16)
742 bind mousePress7 any scrollRight(16)
743
744.fi
745The default key bindings are as follows:
746.nf
747
748 bind ctrl-home any gotoPage(1)
749 bind home any scrollToTopLeft
750 bind ctrl-end any gotoLastPage
751 bind end any scrollToBottomRight
752 bind pgup any pageUp
753 bind backspace any pageUp
754 bind delete any pageUp
755 bind pgdn any pageDown
756 bind space any pageDown
757 bind left any scrollLeft(16)
758 bind right any scrollRight(16)
759 bind up any scrollUp(16)
760 bind down any scrollDown(16)
761 bind o any open
762 bind O any open
763 bind r any reload
764 bind R any reload
765 bind f any find
766 bind F any find
767 bind ctrl-f any find
768 bind ctrl-g any findNext
769 bind ctrl-p any print
770 bind n scrLockOff nextPage
771 bind N scrLockOff nextPage
772 bind n scrLockOn nextPageNoScroll
773 bind N scrLockOn nextPageNoScroll
774 bind p scrLockOff prevPage
775 bind P scrLockOff prevPage
776 bind p scrLockOn prevPageNoScroll
777 bind P scrLockOn prevPageNoScroll
778 bind v any goForward
779 bind b any goBackward
780 bind g any focusToPageNum
781 bind 0 any zoomPercent(125)
782 bind + any zoomIn
783 bind - any zoomOut
784 bind z any zoomFitPage
785 bind w any zoomFitWidth
786 bind alt-f any toggleFullScreenMode
787 bind ctrl-l any redraw
788 bind ctrl-w any closeWindow
789 bind ? any about
790 bind q any quit
791 bind Q any quit
792
793.fi
794Previous versions of xpdf included a "viKeys" X resource. It is no
795longer available, but the following bindings are equivalent:
796.nf
797
798 bind h any scrollLeft(16)
799 bind l any scrollRight(16)
800 bind k any scrollUp(16)
801 bind j any scrollDown(16)
802
803.fi
804.SH "REMOTE SERVER MODE"
805Xpdf can be started in remote server mode by specifying a server name
806(in addition to the file name and page number). For example:
807.PP
808.RS
809xpdf -remote myServer file.pdf
810.RE
811.PP
812If there is currently no xpdf running in server mode with the name
813\'myServer', a new xpdf window will be opened. If another command:
814.PP
815.RS
816xpdf -remote myServer another.pdf 9
817.RE
818.PP
819is issued, a new copy of xpdf will not be started. Instead, the first
820xpdf (the server) will load
821.I another.pdf
822and display page nine. If the file name is the same:
823.PP
824.RS
825xpdf -remote myServer another.pdf 4
826.RE
827.PP
828the xpdf server will simply display the specified page.
829.PP
830The -raise option tells the server to raise its window; it can be
831specified with or without a file name and page number.
832.PP
833The -quit option tells the server to close its window and exit.
834.SH EXIT CODES
835The Xpdf tools use the following exit codes:
836.TP
8370
838No error.
839.TP
8401
841Error opening a PDF file.
842.TP
8432
844Error opening an output file.
845.TP
8463
847Error related to PDF permissions.
848.TP
84999
850Other error.
851.SH AUTHOR
852The xpdf software and documentation are copyright 1996-2007 Glyph &
853Cog, LLC.
854.SH "SEE ALSO"
855.BR pdftops (1),
856.BR pdftotext (1),
857.BR pdfinfo (1),
858.BR pdffonts (1),
859.BR pdftoppm (1),
860.BR pdfimages (1),
861.BR xpdfrc (5)
862.br
863.B http://www.foolabs.com/xpdf/
0864
=== added file '.pc/01_manpage.dpatch/doc/xpdfrc.5'
--- .pc/01_manpage.dpatch/doc/xpdfrc.5 1970-01-01 00:00:00 +0000
+++ .pc/01_manpage.dpatch/doc/xpdfrc.5 2010-04-06 13:42:20 +0000
@@ -0,0 +1,617 @@
1.\" Copyright 2002-2007 Glyph & Cog, LLC
2.TH xpdfrc 5 "27 February 2007"
3.SH NAME
4xpdfrc \- configuration file for Xpdf tools (version 3.02)
5.SH DESCRIPTION
6All of the Xpdf tools read a single configuration file. If you have a
7.I .xpdfrc
8file in your home directory, it will be read. Otherwise, a
9system-wide configuration file will be read from
10.IR /usr/local/etc/xpdfrc ,
11if it exists. (This is its default location; depending on build
12options, it may be placed elsewhere.) On Win32 systems, the
13.I xpdfrc
14file should be placed in the same directory as the executables.
15.PP
16The xpdfrc file consists of a series of configuration options, one
17per line. Blank lines and lines starting with a \'#' (comments) are
18ignored.
19.PP
20The following sections list all of the configuration options, sorted
21into functional groups. There is an examples section at the end.
22.SH INCLUDE FILES
23.TP
24.BI include " config\-file"
25Includes the specified config file. The effect of this is equivalent
26to inserting the contents of
27.I config\-file
28directly into the parent config file in place of the
29.I include
30command. Config files can be nested arbitrarily deeply.
31.SH CHARACTER MAPPING
32.TP
33.BI nameToUnicode " map\-file"
34Specifies a file with the mapping from character names to Unicode.
35This is used to handle PDF fonts that have valid encodings but no
36ToUnicode entry. Each line of a nameToUnicode file looks like this:
37
38.I " " hex\-string name
39
40The
41.I hex\-string
42is the Unicode (UCS-2) character index, and
43.I name
44is the corresponding character name. Multiple nameToUnicode files can
45be used; if a character name is given more than once, the code in the
46last specified file is used. There is a built-in default
47nameToUnicode table with all of Adobe's standard character names.
48.TP
49.BI cidToUnicode " registry\-ordering map\-file"
50Specifies the file with the mapping from character collection to
51Unicode. Each line of a cidToUnicode file represents one character:
52
53.I " " hex\-string
54
55The
56.I hex\-string
57is the Unicode (UCS-2) index for that character. The first line maps
58CID 0, the second line CID 1, etc. File size is determined by size of
59the character collection. Only one file is allowed per character
60collection; the last specified file is used. There are no built-in
61cidToUnicode mappings.
62.TP
63.BI unicodeToUnicode " font\-name\-substring map\-file"
64This is used to work around PDF fonts which have incorrect Unicode
65information. It specifies a file which maps from the given
66(incorrect) Unicode indexes to the correct ones. The mapping will be
67used for any font whose name contains
68.IR font\-name\-substring .
69Each line of a unicodeToUnicode file represents one Unicode character:
70
71.RI " " in\-hex " " out\-hex1 " " out\-hex2 " ..."
72
73The
74.I in\-hex
75field is an input (incorrect) Unicode index, and the rest of the
76fields are one or more output (correct) Unicode indexes. Each
77occurrence of
78.I in\-hex
79will be converted to the specified output sequence.
80.TP
81.BI unicodeMap " encoding\-name map\-file"
82Specifies the file with mapping from Unicode to
83.IR encoding\-name .
84These encodings are used for X display fonts and text output (see
85below). Each line of a unicodeMap file represents a range of one or
86more Unicode characters which maps linearly to a range in the output
87encoding:
88.nf
89
90.I " " in\-start\-hex in\-end\-hex out\-start\-hex
91
92.fi
93Entries for single characters can be abbreviated to:
94.nf
95
96.I " " in\-hex out\-hex
97
98.fi
99The
100.I in\-start\-hex
101and
102.I in\-end\-hex
103fields (or the single
104.I in\-hex
105field) specify the Unicode range. The
106.I out\-start\-hex
107field (or the
108.I out\-hex
109field) specifies the start of the output encoding range. The length
110of the
111.I out\-start\-hex
112(or
113.IR out\-hex )
114string determines the length of the output characters (e.g., UTF-8
115uses different numbers of bytes to represent characters in different
116ranges). Entries must be given in increasing Unicode order. Only one
117file is allowed per encoding; the last specified file is used. The
118.IR Latin1 ,
119.IR ASCII7 ,
120.IR Symbol ,
121.IR ZapfDingbats ,
122.IR UTF-8 ,
123and
124.I UCS-2
125encodings are predefined.
126.TP
127.BI cMapDir " registry\-ordering dir"
128Specifies a search directory,
129.IR dir ,
130for CMaps for the
131.I registry\-ordering
132character collection. There can be multiple directories for a
133particular collection. There are no default CMap directories.
134.TP
135.BI toUnicodeDir " dir"
136Specifies a search directory,
137.IR dir ,
138for ToUnicode CMaps. There can be multiple ToUnicode directories.
139There are no default ToUnicode directories.
140.SH DISPLAY FONTS
141.TP
142.BI displayFontT1 " PDF\-font\-name T1\-file"
143Maps a PDF font,
144.IR PDF\-font\-name ,
145to a Type 1 font for display. The Type 1 font file,
146.IR T1\-file ,
147should be a standard .pfa or .pfb file.
148.TP
149.BI displayFontTT " PDF\-font\-name TT\-file"
150Maps a PDF font,
151.IR PDF\-font\-name ,
152to a TrueType font for display. The TrueType font file,
153.IR TT\-file ,
154should be a standard .ttf file.
155.TP
156.BI displayNamedCIDFontT1 " PDF\-font\-name T1\-file"
157Maps a specific PDF CID (16-bit) font,
158.IR PDF\-font\-name ,
159to a CID font (16-bit PostScript font), for display. There are no
160default CID font mappings.
161.TP
162.BI displayCIDFontT1 " registry\-ordering T1\-file"
163Maps the
164.I registry\-ordering
165character collection to a CID font (16-bit PostScript font), for
166display. This mapping is used if the font name doesn't match any of
167the fonts declared with displayNamedCIDFont* commands. There are no
168default CID font mappings.
169.TP
170.BI displayNamedCIDFontTT " PDF\-font\-name TT\-file"
171Maps a specific PDF CID (16-bit) font,
172.IR PDF\-font\-name ,
173to a (16-bit) TrueType font, for display. There are no default CID
174font mappings.
175.TP
176.BI displayCIDFontTT " registry\-ordering TT\-file"
177Maps the
178.I registry\-ordering
179character collection to a (16-bit) TrueType font, for display. This
180mapping is used if the font name doesn't match any of the fonts
181declared with displayNamedCIDFont* commands. There are no default CID
182font mappings.
183.TP
184.BI fontDir " dir"
185Specifies a search directory for external font files. There can be
186multiple fontDir directories. If a PDF file uses a font but doesn't
187embed it, these directories will be searched for a matching font file.
188These fonts are used by both xpdf (for display) and pdftops (for
189embedding in the generated PostScript). Type 1 fonts must have a
190suffix of ".pfa", ".pfb", ".ps", or no suffix at all. TrueType fonts
191must have a ".ttf" suffix. Other files in these directories will be
192ignored. There are no default fontDir directories.
193.SH POSTSCRIPT CONTROL
194.TP
195.BI psPaperSize " width(pts) height(pts)"
196Sets the paper size for PostScript output. The
197.I width
198and
199.I height
200parameters give the paper size in PostScript points (1 point = 1/72
201inch).
202.TP
203.BR psPaperSize " letter | legal | A4 | A3 | match"
204Sets the paper size for PostScript output to a standard size. The
205default paper size is set when xpdf and pdftops are built, typically
206to "letter" or "A4". This can also be set to "match", which will set
207the paper size to match the size specified in the PDF file.
208.TP
209.BR psImageableArea " llx lly urx ury"
210Sets the imageable area for PostScript output. The four integers are
211the coordinates of the lower-left and upper-right corners of the
212imageable region, specified in points (with the origin being the
213lower-left corner of the paper). This defaults to the full paper
214size; the psPaperSize option will reset the imageable area
215coordinates.
216.TP
217.BR psCrop " yes | no"
218If set to "yes", PostScript output is cropped to the CropBox specified
219in the PDF file; otherwise no cropping is done. This defaults to
220"yes".
221.TP
222.BR psExpandSmaller " yes | no"
223If set to "yes", PDF pages smaller than the PostScript imageable area
224are expanded to fill the imageable area. Otherwise, no scalling is
225done on smaller pages. This defaults to "no".
226.TP
227.BR psShrinkLarger " yes | no"
228If set to yes, PDF pages larger than the PostScript imageable area are
229shrunk to fit the imageable area. Otherwise, no scaling is done on
230larger pages. This defaults to "yes".
231.TP
232.BR psCenter " yes | no"
233If set to yes, PDF pages smaller than the PostScript imageable area
234(after any scaling) are centered in the imageable area. Otherwise,
235they are aligned at the lower-left corner of the imageable area. This
236defaults to "yes".
237.TP
238.BR psDuplex " yes | no"
239If set to "yes", the generated PostScript will set the "Duplex"
240pagedevice entry. This tells duplex-capable printers to enable
241duplexing. This defaults to "no".
242.TP
243.BR psLevel " level1 | level1sep | level2 | level2sep | level3 | level3Sep"
244Sets the PostScript level to generate. This defaults to "level2".
245.TP
246.BI psFont " PDF\-font\-name PS\-font\-name"
247When the
248.I PDF\-font\-name
249font is used in a PDF file, it will be translated to the PostScript
250font
251.IR PS\-font\-name ,
252which is assumed to be resident in the printer. Typically,
253.I PDF\-font\-name
254and
255.I PS\-font\-name
256are the same. By default, only the Base-14 fonts are assumed to be
257resident.
258.TP
259.BI psNamedFont16 " PDF\-font\-name wMode PS\-font\-name encoding"
260When the 16-bit font
261.I PDF\-font\-name
262is used in a PDF file with the
263.I wMode
264writing mode and is not embedded, the
265.I PS\-font\-name
266font is substituted for it. The writing mode must be either \'H' for
267horizontal or \'V' for vertical. The
268.I PS\-font\-name
269font is assumed to be resident in the printer and to use the specified
270encoding (which must have been defined with the unicodeMap command).
271.TP
272.BI psFont16 " registry\-ordering wMode PS\-font\-name encoding"
273When a 16-bit font using the
274.I registry\-ordering
275character collection and
276.I wMode
277writing mode is not embedded and does not match any of the fonts
278declared in psNamedFont16 commands, the
279.I PS\-font\-name
280font is substituted for it. The writing mode must be either \'H' for
281horizontal or \'V' for vertical. The
282.I PS\-font\-name
283font is assumed to be resident in the printer and to use the specified
284writing mode and encoding (which must have been defined with the
285unicodeMap command).
286.TP
287.BR psEmbedType1Fonts " yes | no"
288If set to "no", prevents embedding of Type 1 fonts in generated
289PostScript. This defaults to "yes".
290.TP
291.BR psEmbedTrueTypeFonts " yes | no"
292If set to "no", prevents embedding of TrueType fonts in generated
293PostScript. This defaults to "yes".
294.TP
295.BR psEmbedCIDTrueTypeFonts " yes | no"
296If set to "no", prevents embedding of CID TrueType fonts in generated
297PostScript. For Level 3 PostScript, this generates a CID font, for
298lower levels it generates a non-CID composite font.
299.TP
300.BR psEmbedCIDPostScriptFonts " yes | no"
301If set to "no", prevents embedding of CID PostScript fonts in
302generated PostScript. For Level 3 PostScript, this generates a CID
303font, for lower levels it generates a non-CID composite font.
304.TP
305.BR psPreload " yes | no"
306If set to "yes", PDF forms are converted to PS procedures, and image
307data is preloaded. This uses more memory in the PostScript
308interpreter, but generates significantly smaller PS files in
309situations where, e.g., the same image is drawn on every page of a
310long document. This defaults to "no".
311.TP
312.BR psOPI " yes | no"
313If set to "yes", generates PostScript OPI comments for all images and
314forms which have OPI information. This option is only available if
315the Xpdf tools were compiled with OPI support. This defaults to "no".
316.TP
317.BR psASCIIHex " yes | no"
318If set to "yes", the ASCIIHexEncode filter will be used instead of
319ASCII85Encode for binary data. This defaults to "no".
320.TP
321.BI psFile " file\-or\-command"
322Sets the default PostScript file or print command for xpdf. Commands
323start with a \'|' character; anything else is a file. If the file
324name or command contains spaces it must be quoted. This defaults to
325unset, which tells xpdf to generate a name of the form <file>.ps for a
326PDF file <file>.pdf.
327.TP
328.BI fontDir " dir"
329See the description above, in the DISPLAY FONTS section.
330.SH TEXT CONTROL
331.TP
332.BI textEncoding " encoding\-name"
333Sets the encoding to use for text output. (This can be overridden
334with the "-enc" switch on the command line.) The
335.I encoding\-name
336must be defined with the unicodeMap command (see above). This
337defaults to "Latin1".
338.TP
339.BR textEOL " unix | dos | mac"
340Sets the end-of-line convention to use for text output. The options
341are:
342.nf
343
344 unix = LF
345 dos = CR+LF
346 mac = CR
347
348.fi
349(This can be overridden with the "-eol" switch on the command line.)
350The default value is based on the OS where xpdf and pdftotext were
351built.
352.TP
353.BR textPageBreaks " yes | no"
354If set to "yes", text extraction will insert page breaks (form feed
355characters) between pages. This defaults to "yes".
356.TP
357.BR textKeepTinyChars " yes | no"
358If set to "yes", text extraction will keep all characters. If set to
359"no", text extraction will discard tiny (smaller than 3 point)
360characters after the first 50000 per page, avoiding extremely slow run
361times for PDF files that use special fonts to do shading or
362cross-hatching. This defaults to "no".
363.SH MISCELLANEOUS SETTINGS
364.TP
365.BR initialZoom " \fIpercentage\fR | page | width"
366Sets the initial zoom factor. A number specifies a zoom percentage,
367where 100 means 72 dpi. You may also specify \'page', to fit the page
368to the window size, or \'width', to fit the page width to the window
369width.
370.TP
371.BR continuousView " yes | no"
372If set to "yes", xpdf will start in continuous view mode, i.e., with
373one vertical screoll bar for the whole document. This defaults to
374"no".
375.TP
376.BR enableT1lib " yes | no"
377Enables or disables use of t1lib (a Type 1 font rasterizer). This is
378only relevant if the Xpdf tools were built with t1lib support.
379("enableT1lib" replaces the old "t1libControl" option.) This option
380defaults to "yes".
381.TP
382.BR enableFreeType " yes | no"
383Enables or disables use of FreeType (a TrueType / Type 1 font
384rasterizer). This is only relevant if the Xpdf tools were built with
385FreeType support. ("enableFreeType" replaces the old
386"freetypeControl" option.) This option defaults to "yes".
387.TP
388.BR antialias " yes | no"
389Enables or disables font anti-aliasing in the PDF rasterizer. This
390option affects all font rasterizers. ("antialias" replaces the
391anti-aliasing control provided by the old "t1libControl" and
392"freetypeControl" options.) This default to "yes".
393.TP
394.BR vectorAntialias " yes | no"
395Enables or disables anti-aliasing of vector graphics in the PDF
396rasterizer. This defaults to "yes".
397.TP
398.BR strokeAdjust " yes | no"
399Enables or disables stroke adjustment. This defaults to "yes".
400.TP
401.BR screenType " dispersed | clustered | stochasticClustered"
402Sets the halftone screen type, which will be used when generating a
403monochrome (1-bit) bitmap. The three options are dispersed-dot
404dithering, clustered-dot dithering (with a round dot and 45-degree
405screen angle), and stochastic clustered-dot dithering. By default,
406"stochasticClustered" is used for resolutions of 300 dpi and higher,
407and "dispersed" is used for resolutions lower then 300 dpi.
408.TP
409.BI screenSize " integer"
410Sets the size of the (square) halftone screen threshold matrix. By
411default, this is 4 for dispersed-dot dithering, 10 for clustered-dot
412dithering, and 100 for stochastic clustered-dot dithering.
413.TP
414.BI screenDotRadius " integer"
415Sets the halftone screen dot radius. This is only used when
416screenType is set to stochasticClustered, and it defaults to 2. In
417clustered-dot mode, the dot radius is half of the screen size.
418Dispersed-dot dithering doesn't have a dot radius.
419.TP
420.BI screenGamma " float"
421Sets the halftone screen gamma correction parameter. Gamma values
422greater than 1 make the output brighter; gamma values less than 1 make
423it darker. The default value is 1.
424.TP
425.BI screenBlackThreshold " float"
426When halftoning, all values below this threshold are forced to solid
427black. This parameter is a floating point value between 0 (black) and
4281 (white). The default value is 0.
429.TP
430.BI screenWhiteThreshold " float"
431When halftoning, all values above this threshold are forced to solid
432white. This parameter is a floating point value between 0 (black) and
4331 (white). The default value is 1.
434.TP
435.BI urlCommand " command"
436Sets the command executed when you click on a URL link. The string
437"%s" will be replaced with the URL. (See the example below.) This
438has no default value.
439.TP
440.BI movieCommand " command"
441Sets the command executed when you click on a movie annotation. The
442string "%s" will be replaced with the movie file name. This has no
443default value.
444.TP
445.BI mapNumericCharNames " yes | no"
446If set to "yes", the Xpdf tools will attempt to map various numeric
447character names sometimes used in font subsets. In some cases this
448leads to usable text, and in other cases it leads to gibberish --
449there is no way for Xpdf to tell. This defaults to "yes".
450.TP
451.BI mapUnknownCharNames " yes | no"
452If set to "yes", and mapNumericCharNames is set to "no", the Xpdf
453tools will apply a simple pass-through mapping (Unicode index =
454character code) for all unrecognized glyph names. In some cases, this
455leads to usable text, and in other cases it leads to gibberish --
456there is no way for Xpdf to tell. This defaults to "no".
457.TP
458.BI bind " modifiers-key context command ..."
459Add a key or mouse button binding.
460.I Modifiers
461can be zero or more of:
462.nf
463
464 shift-
465 ctrl-
466 alt-
467
468.fi
469.I Key
470can be a regular ASCII character, or any one of:
471.nf
472
473 space
474 tab
475 return
476 enter
477 backspace
478 insert
479 delete
480 home
481 end
482 pgup
483 pgdn
484 left / right / up / down (arrow keys)
485 f1 .. f35 (function keys)
486 mousePress1 .. mousePress7 (mouse buttons)
487 mouseRelease1 .. mouseRelease7 (mouse buttons)
488
489.fi
490.I Context
491is either "any" or a comma-separated combination of:
492.nf
493
494 fullScreen / window (full screen mode on/off)
495 continuous / singlePage (continuous mode on/off)
496 overLink / offLink (mouse over link or not)
497 scrLockOn / scrLockOff (scroll lock on/off)
498
499.fi
500The context string can include only one of each pair in the above
501list.
502
503.I Command
504is an Xpdf command (see the COMMANDS section of the
505.BR xpdf (1)
506man page for details). Multiple commands are separated by whitespace.
507
508The bind command replaces any existing binding, but only if it was
509defined for the exact same modifiers, key, and context. All tokens
510(modifiers, key, context, commands) are case-sensitive.
511
512Example key bindings:
513.nf
514
515 # bind ctrl-a in any context to the nextPage
516 # command
517 bind ctrl-a any nextPage
518
519 # bind uppercase B, when in continuous mode
520 # with scroll lock on, to the reload command
521 # followed by the prevPage command
522 bind B continuous,scrLockOn reload prevPage
523
524.fi
525See the
526.BR xpdf (1)
527man page for more examples.
528.TP
529.BI unbind " modifiers-key context"
530Removes a key binding established with the bind command. This is most
531useful to remove default key bindings before establishing new ones
532(e.g., if the default key binding is given for "any" context, and you
533want to create new key bindings for multiple contexts).
534.TP
535.BI printCommands " yes | no"
536If set to "yes", drawing commands are printed as they're executed
537(useful for debugging). This defaults to "no".
538.TP
539.BI errQuiet " yes | no"
540If set to "yes", this suppresses all error and warning messages from
541all of the Xpdf tools. This defaults to "no".
542.SH EXAMPLES
543The following is a sample xpdfrc file.
544.nf
545
546# from the Thai support package
547nameToUnicode /usr/local/share/xpdf/Thai.nameToUnicode
548
549# from the Japanese support package
550cidToUnicode Adobe-Japan1 /usr/local/share/xpdf/Adobe-Japan1.cidToUnicode
551unicodeMap JISX0208 /usr/local/share/xpdf/JISX0208.unicodeMap
552cMapDir Adobe-Japan1 /usr/local/share/xpdf/cmap/Adobe-Japan1
553
554# use the Base-14 Type 1 fonts from ghostscript
555displayFontT1 Times-Roman /usr/local/share/ghostscript/fonts/n021003l.pfb
556displayFontT1 Times-Italic /usr/local/share/ghostscript/fonts/n021023l.pfb
557displayFontT1 Times-Bold /usr/local/share/ghostscript/fonts/n021004l.pfb
558displayFontT1 Times-BoldItalic /usr/local/share/ghostscript/fonts/n021024l.pfb
559displayFontT1 Helvetica /usr/local/share/ghostscript/fonts/n019003l.pfb
560displayFontT1 Helvetica-Oblique /usr/local/share/ghostscript/fonts/n019023l.pfb
561displayFontT1 Helvetica-Bold /usr/local/share/ghostscript/fonts/n019004l.pfb
562displayFontT1 Helvetica-BoldOblique /usr/local/share/ghostscript/fonts/n019024l.pfb
563displayFontT1 Courier /usr/local/share/ghostscript/fonts/n022003l.pfb
564displayFontT1 Courier-Oblique /usr/local/share/ghostscript/fonts/n022023l.pfb
565displayFontT1 Courier-Bold /usr/local/share/ghostscript/fonts/n022004l.pfb
566displayFontT1 Courier-BoldOblique /usr/local/share/ghostscript/fonts/n022024l.pfb
567displayFontT1 Symbol /usr/local/share/ghostscript/fonts/s050000l.pfb
568displayFontT1 ZapfDingbats /usr/local/share/ghostscript/fonts/d050000l.pfb
569
570# use the Bakoma Type 1 fonts
571# (this assumes they happen to be installed in /usr/local/fonts/bakoma)
572fontDir /usr/local/fonts/bakoma
573
574# set some PostScript options
575psPaperSize letter
576psDuplex no
577psLevel level2
578psEmbedType1Fonts yes
579psEmbedTrueTypeFonts yes
580psFile "| lpr -Pprinter5"
581
582# assume that the PostScript printer has the Univers and
583# Univers-Bold fonts
584psFont Univers Univers
585psFont Univers-Bold Univers-Bold
586
587# set the text output options
588textEncoding UTF-8
589textEOL unix
590
591# misc options
592t1libControl low
593freetypeControl low
594urlCommand "netscape -remote 'openURL(%s)'"
595
596.fi
597.SH FILES
598.TP
599.B /usr/local/etc/xpdfrc
600This is the default location for the system-wide configuration file.
601Depending on build options, it may be placed elsewhere.
602.TP
603.B $HOME/.xpdfrc
604This is the user's configuration file. If it exists, it will be read
605in place of the system-wide file.
606.SH AUTHOR
607The Xpdf software and documentation are copyright 1996-2007 Glyph &
608Cog, LLC.
609.SH "SEE ALSO"
610.BR xpdf (1),
611.BR pdftops (1),
612.BR pdftotext (1),
613.BR pdfinfo (1),
614.BR pdftoppm (1),
615.BR pdfimages (1)
616.br
617.B http://www.foolabs.com/xpdf/
0618
=== added directory '.pc/02_permissions.dpatch'
=== added directory '.pc/02_permissions.dpatch/xpdf'
=== added file '.pc/02_permissions.dpatch/xpdf/PDFCore.cc'
--- .pc/02_permissions.dpatch/xpdf/PDFCore.cc 1970-01-01 00:00:00 +0000
+++ .pc/02_permissions.dpatch/xpdf/PDFCore.cc 2010-04-06 13:42:20 +0000
@@ -0,0 +1,2044 @@
1//========================================================================
2//
3// PDFCore.cc
4//
5// Copyright 2004 Glyph & Cog, LLC
6//
7//========================================================================
8
9#include <aconf.h>
10
11#ifdef USE_GCC_PRAGMAS
12#pragma implementation
13#endif
14
15#include <math.h>
16#include "GString.h"
17#include "GList.h"
18#include "GlobalParams.h"
19#include "Splash.h"
20#include "SplashBitmap.h"
21#include "SplashPattern.h"
22#include "SplashPath.h"
23#include "Error.h"
24#include "ErrorCodes.h"
25#include "PDFDoc.h"
26#include "Link.h"
27#include "TextOutputDev.h"
28#include "CoreOutputDev.h"
29#include "PDFCore.h"
30
31//------------------------------------------------------------------------
32// PDFCorePage
33//------------------------------------------------------------------------
34
35PDFCorePage::PDFCorePage(int pageA, int wA, int hA, int tileWA, int tileHA) {
36 page = pageA;
37 tiles = new GList();
38 w = wA;
39 h = hA;
40 tileW = tileWA;
41 tileH = tileHA;
42 links = NULL;
43 text = NULL;
44}
45
46PDFCorePage::~PDFCorePage() {
47 deleteGList(tiles, PDFCoreTile);
48 if (links) {
49 delete links;
50 }
51 if (text) {
52 delete text;
53 }
54}
55
56//------------------------------------------------------------------------
57// PDFCoreTile
58//------------------------------------------------------------------------
59
60PDFCoreTile::PDFCoreTile(int xDestA, int yDestA) {
61 xMin = 0;
62 yMin = 0;
63 xMax = 0;
64 yMax = 0;
65 xDest = xDestA;
66 yDest = yDestA;
67 bitmap = NULL;
68}
69
70PDFCoreTile::~PDFCoreTile() {
71 if (bitmap) {
72 delete bitmap;
73 }
74}
75
76
77//------------------------------------------------------------------------
78// PDFCore
79//------------------------------------------------------------------------
80
81PDFCore::PDFCore(SplashColorMode colorModeA, int bitmapRowPadA,
82 GBool reverseVideoA, SplashColorPtr paperColorA,
83 GBool incrementalUpdate) {
84 int i;
85
86 doc = NULL;
87 continuousMode = globalParams->getContinuousView();
88 drawAreaWidth = drawAreaHeight = 0;
89 maxPageW = totalDocH = 0;
90 pageY = NULL;
91 topPage = 0;
92 scrollX = scrollY = 0;
93 zoom = defZoom;
94 dpi = 0;
95 rotate = 0;
96
97 selectPage = 0;
98 selectULX = selectLRX = 0;
99 selectULY = selectLRY = 0;
100 dragging = gFalse;
101 lastDragLeft = lastDragTop = gTrue;
102
103 historyCur = pdfHistorySize - 1;
104 historyBLen = historyFLen = 0;
105 for (i = 0; i < pdfHistorySize; ++i) {
106 history[i].fileName = NULL;
107 }
108
109
110 pages = new GList();
111 curTile = NULL;
112
113 splashColorCopy(paperColor, paperColorA);
114 out = new CoreOutputDev(colorModeA, bitmapRowPadA,
115 reverseVideoA, paperColorA, incrementalUpdate,
116 &redrawCbk, this);
117 out->startDoc(NULL);
118}
119
120PDFCore::~PDFCore() {
121 int i;
122
123 if (doc) {
124 delete doc;
125 }
126 for (i = 0; i < pdfHistorySize; ++i) {
127 if (history[i].fileName) {
128 delete history[i].fileName;
129 }
130 }
131 gfree(pageY);
132 deleteGList(pages, PDFCorePage);
133 delete out;
134}
135
136int PDFCore::loadFile(GString *fileName, GString *ownerPassword,
137 GString *userPassword) {
138 int err;
139
140 setBusyCursor(gTrue);
141 err = loadFile2(new PDFDoc(fileName->copy(), ownerPassword, userPassword,
142 this));
143 setBusyCursor(gFalse);
144 return err;
145}
146
147#ifdef WIN32
148int PDFCore::loadFile(wchar_t *fileName, int fileNameLen,
149 GString *ownerPassword, GString *userPassword) {
150 int err;
151
152 setBusyCursor(gTrue);
153 err = loadFile2(new PDFDoc(fileName, fileNameLen,
154 ownerPassword, userPassword, this));
155 setBusyCursor(gFalse);
156 return err;
157}
158#endif
159
160int PDFCore::loadFile(BaseStream *stream, GString *ownerPassword,
161 GString *userPassword) {
162 int err;
163
164 setBusyCursor(gTrue);
165 err = loadFile2(new PDFDoc(stream, ownerPassword, userPassword, this));
166 setBusyCursor(gFalse);
167 return err;
168}
169
170void PDFCore::loadDoc(PDFDoc *docA) {
171 setBusyCursor(gTrue);
172 loadFile2(docA);
173 setBusyCursor(gFalse);
174}
175
176int PDFCore::loadFile2(PDFDoc *newDoc) {
177 int err;
178 double w, h, t;
179 int i;
180
181 // open the PDF file
182 if (!newDoc->isOk()) {
183 err = newDoc->getErrorCode();
184 delete newDoc;
185 return err;
186 }
187
188 // replace old document
189 if (doc) {
190 delete doc;
191 }
192 doc = newDoc;
193 if (out) {
194 out->startDoc(doc->getXRef());
195 }
196
197 // nothing displayed yet
198 topPage = -99;
199 while (pages->getLength() > 0) {
200 delete (PDFCorePage *)pages->del(0);
201 }
202
203 // compute the max unscaled page size
204 maxUnscaledPageW = maxUnscaledPageH = 0;
205 for (i = 1; i <= doc->getNumPages(); ++i) {
206 w = doc->getPageCropWidth(i);
207 h = doc->getPageCropHeight(i);
208 if (doc->getPageRotate(i) == 90 || doc->getPageRotate(i) == 270) {
209 t = w; w = h; h = t;
210 }
211 if (w > maxUnscaledPageW) {
212 maxUnscaledPageW = w;
213 }
214 if (h > maxUnscaledPageH) {
215 maxUnscaledPageH = h;
216 }
217 }
218
219 return errNone;
220}
221
222void PDFCore::clear() {
223 if (!doc) {
224 return;
225 }
226
227 // no document
228 delete doc;
229 doc = NULL;
230 out->clear();
231
232 // no page displayed
233 topPage = -99;
234 while (pages->getLength() > 0) {
235 delete (PDFCorePage *)pages->del(0);
236 }
237
238 // redraw
239 scrollX = scrollY = 0;
240 redrawWindow(0, 0, drawAreaWidth, drawAreaHeight, gTrue);
241 updateScrollbars();
242}
243
244PDFDoc *PDFCore::takeDoc(GBool redraw) {
245 PDFDoc *docA;
246
247 if (!doc) {
248 return NULL;
249 }
250
251 // no document
252 docA = doc;
253 doc = NULL;
254 out->clear();
255
256 // no page displayed
257 topPage = -99;
258 while (pages->getLength() > 0) {
259 delete (PDFCorePage *)pages->del(0);
260 }
261
262 // redraw
263 scrollX = scrollY = 0;
264 if (redraw) {
265 redrawWindow(0, 0, drawAreaWidth, drawAreaHeight, gTrue);
266 updateScrollbars();
267 }
268
269 return docA;
270}
271
272void PDFCore::displayPage(int topPageA, double zoomA, int rotateA,
273 GBool scrollToTop, GBool addToHist) {
274 int scrollXA, scrollYA;
275
276 scrollXA = scrollX;
277 if (continuousMode) {
278 scrollYA = -1;
279 } else if (scrollToTop) {
280 scrollYA = 0;
281 } else {
282 scrollYA = scrollY;
283 }
284 if (zoomA != zoom) {
285 scrollXA = 0;
286 scrollYA = continuousMode ? -1 : 0;
287 }
288
289 dragging = gFalse;
290 lastDragLeft = lastDragTop = gTrue;
291
292 update(topPageA, scrollXA, scrollYA, zoomA, rotateA, gTrue, addToHist);
293}
294
295void PDFCore::displayDest(LinkDest *dest, double zoomA, int rotateA,
296 GBool addToHist) {
297 Ref pageRef;
298 int topPageA;
299 int dx, dy, scrollXA, scrollYA;
300
301 if (dest->isPageRef()) {
302 pageRef = dest->getPageRef();
303 topPageA = doc->findPage(pageRef.num, pageRef.gen);
304 } else {
305 topPageA = dest->getPageNum();
306 }
307 if (topPageA <= 0 || topPageA > doc->getNumPages()) {
308 topPageA = 1;
309 }
310 scrollXA = scrollX;
311 scrollYA = continuousMode ? -1 : scrollY;
312 switch (dest->getKind()) {
313 case destXYZ:
314 cvtUserToDev(topPageA, dest->getLeft(), dest->getTop(), &dx, &dy);
315 scrollXA = dest->getChangeLeft() ? dx : scrollX;
316 if (dest->getChangeTop()) {
317 scrollYA = dy;
318 } else {
319 if (topPage <= 0) {
320 scrollYA = 0;
321 } else if (continuousMode) {
322 scrollYA = scrollY - pageY[topPage - 1];
323 } else {
324 scrollYA = scrollY;
325 }
326 }
327 if (continuousMode && topPage > 0) {
328 scrollYA += pageY[topPageA - 1];
329 }
330 //~ what is the zoom parameter?
331 break;
332 case destFit:
333 case destFitB:
334 //~ do fit
335 scrollXA = 0;
336 scrollYA = continuousMode ? -1 : 0;
337 break;
338 case destFitH:
339 case destFitBH:
340 //~ do fit
341 cvtUserToDev(topPageA, 0, dest->getTop(), &dx, &dy);
342 if (continuousMode && topPage > 0) {
343 dy += pageY[topPageA - 1];
344 }
345 scrollXA = 0;
346 scrollYA = dy;
347 break;
348 case destFitV:
349 case destFitBV:
350 //~ do fit
351 cvtUserToDev(topPageA, dest->getLeft(), 0, &dx, &dy);
352 scrollXA = dx;
353 scrollYA = continuousMode ? -1 : 0;
354 break;
355 case destFitR:
356 //~ do fit
357 cvtUserToDev(topPageA, dest->getLeft(), dest->getTop(), &dx, &dy);
358 if (continuousMode && topPage > 0) {
359 dy += pageY[topPageA - 1];
360 }
361 scrollXA = dx;
362 scrollYA = dy;
363 break;
364 }
365 update(topPageA, scrollXA, scrollYA, zoom, rotate, gFalse,
366 addToHist && topPageA != topPage);
367}
368
369void PDFCore::update(int topPageA, int scrollXA, int scrollYA,
370 double zoomA, int rotateA, GBool force, GBool addToHist) {
371 double hDPI, vDPI, dpiA, uw, uh, ut;
372 int w, h, t, x0, x1, y0, y1, x, y;
373 int rot;
374 int pg0, pg1;
375 PDFCoreTile *tile;
376 PDFCorePage *page;
377 PDFHistory *hist;
378 SplashColor xorColor;
379 GBool needUpdate;
380 int i, j;
381
382 // check for document and valid page number
383 if (!doc) {
384 // save the new settings
385 zoom = zoomA;
386 rotate = rotateA;
387 return;
388 }
389 if (topPageA <= 0 || topPageA > doc->getNumPages()) {
390 return;
391 }
392
393 needUpdate = gFalse;
394
395 // check for changes to the PDF file
396 if ((force || (!continuousMode && topPage != topPageA)) &&
397 checkForNewFile()) {
398 if (loadFile(doc->getFileName()) == errNone) {
399 if (topPageA > doc->getNumPages()) {
400 topPageA = doc->getNumPages();
401 }
402 needUpdate = gTrue;
403 }
404 }
405
406 // compute the DPI
407 if (continuousMode) {
408 uw = maxUnscaledPageW;
409 uh = maxUnscaledPageH;
410 rot = rotateA;
411 } else {
412 uw = doc->getPageCropWidth(topPageA);
413 uh = doc->getPageCropHeight(topPageA);
414 rot = rotateA + doc->getPageRotate(topPageA);
415 if (rot >= 360) {
416 rot -= 360;
417 } else if (rot < 0) {
418 rot += 360;
419 }
420 }
421 if (rot == 90 || rot == 270) {
422 ut = uw; uw = uh; uh = ut;
423 }
424 if (zoomA == zoomPage) {
425 hDPI = (drawAreaWidth / uw) * 72;
426 if (continuousMode) {
427 vDPI = ((drawAreaHeight - continuousModePageSpacing) / uh) * 72;
428 } else {
429 vDPI = (drawAreaHeight / uh) * 72;
430 }
431 dpiA = (hDPI < vDPI) ? hDPI : vDPI;
432 } else if (zoomA == zoomWidth) {
433 dpiA = (drawAreaWidth / uw) * 72;
434 } else {
435 dpiA = 0.01 * zoomA * 72;
436 }
437 // this can happen if the window hasn't been sized yet
438 if (dpiA <= 0) {
439 dpiA = 1;
440 }
441
442 // if the display properties have changed, create a new PDFCorePage
443 // object
444 if (force || pages->getLength() == 0 ||
445 (!continuousMode && topPageA != topPage) ||
446 zoomA != zoom || dpiA != dpi || rotateA != rotate) {
447 needUpdate = gTrue;
448 setSelection(0, 0, 0, 0, 0);
449 while (pages->getLength() > 0) {
450 delete (PDFCorePage *)pages->del(0);
451 }
452 zoom = zoomA;
453 rotate = rotateA;
454 dpi = dpiA;
455 if (continuousMode) {
456 maxPageW = totalDocH = 0;
457 pageY = (int *)greallocn(pageY, doc->getNumPages(), sizeof(int));
458 for (i = 1; i <= doc->getNumPages(); ++i) {
459 pageY[i-1] = totalDocH;
460 w = (int)((doc->getPageCropWidth(i) * dpi) / 72 + 0.5);
461 h = (int)((doc->getPageCropHeight(i) * dpi) / 72 + 0.5);
462 rot = rotate + doc->getPageRotate(i);
463 if (rot >= 360) {
464 rot -= 360;
465 } else if (rot < 0) {
466 rot += 360;
467 }
468 if (rot == 90 || rot == 270) {
469 t = w; w = h; h = t;
470 }
471 if (w > maxPageW) {
472 maxPageW = w;
473 }
474 totalDocH += h;
475 if (i < doc->getNumPages()) {
476 totalDocH += continuousModePageSpacing;
477 }
478 }
479 } else {
480 rot = rotate + doc->getPageRotate(topPageA);
481 if (rot >= 360) {
482 rot -= 360;
483 } else if (rot < 0) {
484 rot += 360;
485 }
486 addPage(topPageA, rot);
487 }
488 } else {
489 // erase the selection
490 if (selectULX != selectLRX && selectULY != selectLRY) {
491 xorColor[0] = xorColor[1] = xorColor[2] = 0xff;
492 xorRectangle(selectPage, selectULX, selectULY, selectLRX, selectLRY,
493 new SplashSolidColor(xorColor));
494 }
495 }
496 if (continuousMode) {
497 page = NULL; // make gcc happy
498 } else {
499 page = (PDFCorePage *)pages->get(0);
500 }
501 topPage = topPageA;
502
503 // adjust the scroll position
504 scrollX = scrollXA;
505 if (continuousMode && scrollYA < 0) {
506 scrollY = pageY[topPage - 1];
507 } else {
508 scrollY = scrollYA;
509 }
510 w = continuousMode ? maxPageW : page->w;
511 if (scrollX > w - drawAreaWidth) {
512 scrollX = w - drawAreaWidth;
513 }
514 if (scrollX < 0) {
515 scrollX = 0;
516 }
517 h = continuousMode ? totalDocH : page->h;
518 if (scrollY > h - drawAreaHeight) {
519 scrollY = h - drawAreaHeight;
520 }
521 if (scrollY < 0) {
522 scrollY = 0;
523 }
524
525 // find topPage, and the first and last pages to be rasterized
526 if (continuousMode) {
527 //~ should use a binary search
528 for (i = 2; i <= doc->getNumPages(); ++i) {
529 if (pageY[i-1] > scrollY - drawAreaHeight / 2) {
530 break;
531 }
532 }
533 pg0 = i - 1;
534 for (i = pg0 + 1; i <= doc->getNumPages(); ++i) {
535 if (pageY[i-1] > scrollY) {
536 break;
537 }
538 }
539 topPage = i - 1;
540 for (i = topPage + 1; i <= doc->getNumPages(); ++i) {
541 if (pageY[i-1] > scrollY + drawAreaHeight + drawAreaHeight / 2) {
542 break;
543 }
544 }
545 pg1 = i - 1;
546
547 // delete pages that are no longer needed and insert new pages
548 // objects that are needed
549 while (pages->getLength() > 0 &&
550 ((PDFCorePage *)pages->get(0))->page < pg0) {
551 delete (PDFCorePage *)pages->del(0);
552 }
553 i = pages->getLength() - 1;
554 while (i > 0 && ((PDFCorePage *)pages->get(i))->page > pg1) {
555 delete (PDFCorePage *)pages->del(i--);
556 }
557 j = pages->getLength() > 0 ? ((PDFCorePage *)pages->get(0))->page - 1
558 : pg1;
559 for (i = pg0; i <= j; ++i) {
560 rot = rotate + doc->getPageRotate(i);
561 if (rot >= 360) {
562 rot -= 360;
563 } else if (rot < 0) {
564 rot += 360;
565 }
566 addPage(i, rot);
567 }
568 j = ((PDFCorePage *)pages->get(pages->getLength() - 1))->page;
569 for (i = j + 1; i <= pg1; ++i) {
570 rot = rotate + doc->getPageRotate(i);
571 if (rot >= 360) {
572 rot -= 360;
573 } else if (rot < 0) {
574 rot += 360;
575 }
576 addPage(i, rot);
577 }
578
579 } else {
580 pg0 = pg1 = topPage;
581 }
582
583 // delete tiles that are no longer needed
584 for (i = 0; i < pages->getLength(); ++i) {
585 page = (PDFCorePage *)pages->get(i);
586 j = 0;
587 while (j < page->tiles->getLength()) {
588 tile = (PDFCoreTile *)page->tiles->get(j);
589 if (continuousMode) {
590 y0 = pageY[page->page - 1] + tile->yMin;
591 y1 = pageY[page->page - 1] + tile->yMax;
592 } else {
593 y0 = tile->yMin;
594 y1 = tile->yMax;
595 }
596 if (tile->xMax < scrollX - drawAreaWidth / 2 ||
597 tile->xMin > scrollX + drawAreaWidth + drawAreaWidth / 2 ||
598 y1 < scrollY - drawAreaHeight / 2 ||
599 y0 > scrollY + drawAreaHeight + drawAreaHeight / 2) {
600 delete (PDFCoreTile *)page->tiles->del(j);
601 } else {
602 ++j;
603 }
604 }
605 }
606
607 // update page positions
608 for (i = 0; i < pages->getLength(); ++i) {
609 page = (PDFCorePage *)pages->get(i);
610 page->xDest = -scrollX;
611 if (continuousMode) {
612 page->yDest = pageY[page->page - 1] - scrollY;
613 } else {
614 page->yDest = -scrollY;
615 }
616 if (continuousMode) {
617 if (page->w < maxPageW) {
618 page->xDest += (maxPageW - page->w) / 2;
619 }
620 if (maxPageW < drawAreaWidth) {
621 page->xDest += (drawAreaWidth - maxPageW) / 2;
622 }
623 } else if (page->w < drawAreaWidth) {
624 page->xDest += (drawAreaWidth - page->w) / 2;
625 }
626 if (continuousMode && totalDocH < drawAreaHeight) {
627 page->yDest += (drawAreaHeight - totalDocH) / 2;
628 } else if (!continuousMode && page->h < drawAreaHeight) {
629 page->yDest += (drawAreaHeight - page->h) / 2;
630 }
631 }
632
633 // rasterize any new tiles
634 for (i = 0; i < pages->getLength(); ++i) {
635 page = (PDFCorePage *)pages->get(i);
636 x0 = page->xDest;
637 x1 = x0 + page->w - 1;
638 if (x0 < -drawAreaWidth / 2) {
639 x0 = -drawAreaWidth / 2;
640 }
641 if (x1 > drawAreaWidth + drawAreaWidth / 2) {
642 x1 = drawAreaWidth + drawAreaWidth / 2;
643 }
644 x0 = ((x0 - page->xDest) / page->tileW) * page->tileW;
645 x1 = ((x1 - page->xDest) / page->tileW) * page->tileW;
646 y0 = page->yDest;
647 y1 = y0 + page->h - 1;
648 if (y0 < -drawAreaHeight / 2) {
649 y0 = -drawAreaHeight / 2;
650 }
651 if (y1 > drawAreaHeight + drawAreaHeight / 2) {
652 y1 = drawAreaHeight + drawAreaHeight / 2;
653 }
654 y0 = ((y0 - page->yDest) / page->tileH) * page->tileH;
655 y1 = ((y1 - page->yDest) / page->tileH) * page->tileH;
656 for (y = y0; y <= y1; y += page->tileH) {
657 for (x = x0; x <= x1; x += page->tileW) {
658 needTile(page, x, y);
659 }
660 }
661 }
662
663 // update tile positions
664 for (i = 0; i < pages->getLength(); ++i) {
665 page = (PDFCorePage *)pages->get(i);
666 for (j = 0; j < page->tiles->getLength(); ++j) {
667 tile = (PDFCoreTile *)page->tiles->get(j);
668 tile->xDest = tile->xMin - scrollX;
669 if (continuousMode) {
670 tile->yDest = tile->yMin + pageY[page->page - 1] - scrollY;
671 } else {
672 tile->yDest = tile->yMin - scrollY;
673 }
674 if (continuousMode) {
675 if (page->w < maxPageW) {
676 tile->xDest += (maxPageW - page->w) / 2;
677 }
678 if (maxPageW < drawAreaWidth) {
679 tile->xDest += (drawAreaWidth - maxPageW) / 2;
680 }
681 } else if (page->w < drawAreaWidth) {
682 tile->xDest += (drawAreaWidth - page->w) / 2;
683 }
684 if (continuousMode && totalDocH < drawAreaHeight) {
685 tile->yDest += (drawAreaHeight - totalDocH) / 2;
686 } else if (!continuousMode && page->h < drawAreaHeight) {
687 tile->yDest += (drawAreaHeight - page->h) / 2;
688 }
689 }
690 }
691
692 // redraw the selection
693 if (selectULX != selectLRX && selectULY != selectLRY) {
694 xorColor[0] = xorColor[1] = xorColor[2] = 0xff;
695 xorRectangle(selectPage, selectULX, selectULY, selectLRX, selectLRY,
696 new SplashSolidColor(xorColor));
697 }
698
699 // redraw the window
700 redrawWindow(0, 0, drawAreaWidth, drawAreaHeight, needUpdate);
701 updateScrollbars();
702
703 // add to history
704 if (addToHist) {
705 if (++historyCur == pdfHistorySize) {
706 historyCur = 0;
707 }
708 hist = &history[historyCur];
709 if (hist->fileName) {
710 delete hist->fileName;
711 }
712 if (doc->getFileName()) {
713 hist->fileName = doc->getFileName()->copy();
714 } else {
715 hist->fileName = NULL;
716 }
717 hist->page = topPage;
718 if (historyBLen < pdfHistorySize) {
719 ++historyBLen;
720 }
721 historyFLen = 0;
722 }
723}
724
725void PDFCore::addPage(int pg, int rot) {
726 PDFCorePage *page;
727 int w, h, t, tileW, tileH, i;
728
729 w = (int)((doc->getPageCropWidth(pg) * dpi) / 72 + 0.5);
730 h = (int)((doc->getPageCropHeight(pg) * dpi) / 72 + 0.5);
731 if (rot == 90 || rot == 270) {
732 t = w; w = h; h = t;
733 }
734 tileW = 2 * drawAreaWidth;
735 if (tileW < 1500) {
736 tileW = 1500;
737 }
738 if (tileW > w) {
739 tileW = w;
740 }
741 tileH = 2 * drawAreaHeight;
742 if (tileH < 1500) {
743 tileH = 1500;
744 }
745 if (tileH > h) {
746 tileH = h;
747 }
748 page = new PDFCorePage(pg, w, h, tileW, tileH);
749 for (i = 0;
750 i < pages->getLength() && pg > ((PDFCorePage *)pages->get(i))->page;
751 ++i) ;
752 pages->insert(i, page);
753}
754
755void PDFCore::needTile(PDFCorePage *page, int x, int y) {
756 PDFCoreTile *tile;
757 TextOutputDev *textOut;
758 int xDest, yDest, sliceW, sliceH;
759 int i;
760
761 for (i = 0; i < page->tiles->getLength(); ++i) {
762 tile = (PDFCoreTile *)page->tiles->get(i);
763 if (x == tile->xMin && y == tile->yMin) {
764 return;
765 }
766 }
767
768 setBusyCursor(gTrue);
769
770 sliceW = page->tileW;
771 if (x + sliceW > page->w) {
772 sliceW = page->w - x;
773 }
774 sliceH = page->tileH;
775 if (y + sliceH > page->h) {
776 sliceH = page->h - y;
777 }
778
779 xDest = x - scrollX;
780 if (continuousMode) {
781 yDest = y + pageY[page->page - 1] - scrollY;
782 } else {
783 yDest = y - scrollY;
784 }
785 if (continuousMode) {
786 if (page->w < maxPageW) {
787 xDest += (maxPageW - page->w) / 2;
788 }
789 if (maxPageW < drawAreaWidth) {
790 xDest += (drawAreaWidth - maxPageW) / 2;
791 }
792 } else if (page->w < drawAreaWidth) {
793 xDest += (drawAreaWidth - page->w) / 2;
794 }
795 if (continuousMode && totalDocH < drawAreaHeight) {
796 yDest += (drawAreaHeight - totalDocH) / 2;
797 } else if (!continuousMode && page->h < drawAreaHeight) {
798 yDest += (drawAreaHeight - page->h) / 2;
799 }
800 curTile = tile = newTile(xDest, yDest);
801 curPage = page;
802 tile->xMin = x;
803 tile->yMin = y;
804 tile->xMax = x + sliceW;
805 tile->yMax = y + sliceH;
806 tile->edges = 0;
807 if (tile->xMin == 0) {
808 tile->edges |= pdfCoreTileLeftEdge;
809 }
810 if (tile->xMax == page->w) {
811 tile->edges |= pdfCoreTileRightEdge;
812 }
813 if (continuousMode) {
814 if (tile->yMin == 0) {
815 tile->edges |= pdfCoreTileTopSpace;
816 if (page->page == 1) {
817 tile->edges |= pdfCoreTileTopEdge;
818 }
819 }
820 if (tile->yMax == page->h) {
821 tile->edges |= pdfCoreTileBottomSpace;
822 if (page->page == doc->getNumPages()) {
823 tile->edges |= pdfCoreTileBottomEdge;
824 }
825 }
826 } else {
827 if (tile->yMin == 0) {
828 tile->edges |= pdfCoreTileTopEdge;
829 }
830 if (tile->yMax == page->h) {
831 tile->edges |= pdfCoreTileBottomEdge;
832 }
833 }
834 doc->displayPageSlice(out, page->page, dpi, dpi, rotate,
835 gFalse, gTrue, gFalse, x, y, sliceW, sliceH);
836 tile->bitmap = out->takeBitmap();
837 memcpy(tile->ctm, out->getDefCTM(), 6 * sizeof(double));
838 memcpy(tile->ictm, out->getDefICTM(), 6 * sizeof(double));
839 if (!page->links) {
840 page->links = doc->getLinks(page->page);
841 }
842 if (!page->text) {
843 if ((textOut = new TextOutputDev(NULL, gTrue, gFalse, gFalse))) {
844 doc->displayPage(textOut, page->page, dpi, dpi, rotate,
845 gFalse, gTrue, gFalse);
846 page->text = textOut->takeText();
847 delete textOut;
848 }
849 }
850 page->tiles->append(tile);
851 curTile = NULL;
852 curPage = NULL;
853
854 setBusyCursor(gFalse);
855}
856
857GBool PDFCore::gotoNextPage(int inc, GBool top) {
858 int pg, scrollYA;
859
860 if (!doc || doc->getNumPages() == 0 || topPage >= doc->getNumPages()) {
861 return gFalse;
862 }
863 if ((pg = topPage + inc) > doc->getNumPages()) {
864 pg = doc->getNumPages();
865 }
866 if (continuousMode) {
867 scrollYA = -1;
868 } else if (top) {
869 scrollYA = 0;
870 } else {
871 scrollYA = scrollY;
872 }
873 update(pg, scrollX, scrollYA, zoom, rotate, gFalse, gTrue);
874 return gTrue;
875}
876
877GBool PDFCore::gotoPrevPage(int dec, GBool top, GBool bottom) {
878 int pg, scrollYA;
879
880 if (!doc || doc->getNumPages() == 0 || topPage <= 1) {
881 return gFalse;
882 }
883 if ((pg = topPage - dec) < 1) {
884 pg = 1;
885 }
886 if (continuousMode) {
887 scrollYA = -1;
888 } else if (top) {
889 scrollYA = 0;
890 } else if (bottom) {
891 scrollYA = ((PDFCorePage *)pages->get(0))->h - drawAreaHeight;
892 if (scrollYA < 0) {
893 scrollYA = 0;
894 }
895 } else {
896 scrollYA = scrollY;
897 }
898 update(pg, scrollX, scrollYA, zoom, rotate, gFalse, gTrue);
899 return gTrue;
900}
901
902GBool PDFCore::gotoNamedDestination(GString *dest) {
903 LinkDest *d;
904
905 if (!doc) {
906 return gFalse;
907 }
908 if (!(d = doc->findDest(dest))) {
909 return gFalse;
910 }
911 displayDest(d, zoom, rotate, gTrue);
912 delete d;
913 return gTrue;
914}
915
916GBool PDFCore::goForward() {
917 int pg;
918
919 if (historyFLen == 0) {
920 return gFalse;
921 }
922 if (++historyCur == pdfHistorySize) {
923 historyCur = 0;
924 }
925 --historyFLen;
926 ++historyBLen;
927 if (!doc || history[historyCur].fileName->cmp(doc->getFileName()) != 0) {
928 if (loadFile(history[historyCur].fileName) != errNone) {
929 return gFalse;
930 }
931 }
932 pg = history[historyCur].page;
933 update(pg, scrollX, continuousMode ? -1 : scrollY,
934 zoom, rotate, gFalse, gFalse);
935 return gTrue;
936}
937
938GBool PDFCore::goBackward() {
939 int pg;
940
941 if (historyBLen <= 1) {
942 return gFalse;
943 }
944 if (--historyCur < 0) {
945 historyCur = pdfHistorySize - 1;
946 }
947 --historyBLen;
948 ++historyFLen;
949 if (!doc || history[historyCur].fileName->cmp(doc->getFileName()) != 0) {
950 if (loadFile(history[historyCur].fileName) != errNone) {
951 return gFalse;
952 }
953 }
954 pg = history[historyCur].page;
955 update(pg, scrollX, continuousMode ? -1 : scrollY,
956 zoom, rotate, gFalse, gFalse);
957 return gTrue;
958}
959
960void PDFCore::scrollLeft(int nCols) {
961 scrollTo(scrollX - nCols, scrollY);
962}
963
964void PDFCore::scrollRight(int nCols) {
965 scrollTo(scrollX + nCols, scrollY);
966}
967
968void PDFCore::scrollUp(int nLines) {
969 scrollTo(scrollX, scrollY - nLines);
970}
971
972void PDFCore::scrollUpPrevPage(int nLines) {
973 if (!continuousMode && scrollY == 0) {
974 gotoPrevPage(1, gFalse, gTrue);
975 } else {
976 scrollTo(scrollX, scrollY - nLines);
977 }
978}
979
980void PDFCore::scrollDown(int nLines) {
981 scrollTo(scrollX, scrollY + nLines);
982}
983
984void PDFCore::scrollDownNextPage(int nLines) {
985 if (!continuousMode &&
986 scrollY >= ((PDFCorePage *)pages->get(0))->h - drawAreaHeight) {
987 gotoNextPage(1, gTrue);
988 } else {
989 scrollTo(scrollX, scrollY + nLines);
990 }
991}
992
993void PDFCore::scrollPageUp() {
994 if (!continuousMode && scrollY == 0) {
995 gotoPrevPage(1, gFalse, gTrue);
996 } else {
997 scrollTo(scrollX, scrollY - drawAreaHeight);
998 }
999}
1000
1001void PDFCore::scrollPageDown() {
1002 if (!continuousMode &&
1003 scrollY >= ((PDFCorePage *)pages->get(0))->h - drawAreaHeight) {
1004 gotoNextPage(1, gTrue);
1005 } else {
1006 scrollTo(scrollX, scrollY + drawAreaHeight);
1007 }
1008}
1009
1010void PDFCore::scrollTo(int x, int y) {
1011 update(topPage, x, y < 0 ? 0 : y, zoom, rotate, gFalse, gFalse);
1012}
1013
1014void PDFCore::scrollToLeftEdge() {
1015 update(topPage, 0, scrollY, zoom, rotate, gFalse, gFalse);
1016}
1017
1018void PDFCore::scrollToRightEdge() {
1019 PDFCorePage *page;
1020
1021 page = (PDFCorePage *)pages->get(0);
1022 update(topPage, page->w - drawAreaWidth, scrollY,
1023 zoom, rotate, gFalse, gFalse);
1024}
1025
1026void PDFCore::scrollToTopEdge() {
1027 int y;
1028
1029 y = continuousMode ? pageY[topPage - 1] : 0;
1030 update(topPage, scrollX, y, zoom, rotate, gFalse, gFalse);
1031}
1032
1033void PDFCore::scrollToBottomEdge() {
1034 PDFCorePage *page;
1035 int y, i;
1036
1037 for (i = pages->getLength() - 1; i > 0; --i) {
1038 page = (PDFCorePage *)pages->get(i);
1039 if (page->yDest < drawAreaHeight) {
1040 break;
1041 }
1042 }
1043 page = (PDFCorePage *)pages->get(i);
1044 if (continuousMode) {
1045 y = pageY[page->page - 1] + page->h - drawAreaHeight;
1046 } else {
1047 y = page->h - drawAreaHeight;
1048 }
1049 update(topPage, scrollX, y, zoom, rotate, gFalse, gFalse);
1050}
1051
1052void PDFCore::scrollToTopLeft() {
1053 int y;
1054
1055 y = continuousMode ? pageY[topPage - 1] : 0;
1056 update(topPage, 0, y, zoom, rotate, gFalse, gFalse);
1057}
1058
1059void PDFCore::scrollToBottomRight() {
1060 PDFCorePage *page;
1061 int x, y, i;
1062
1063 for (i = pages->getLength() - 1; i > 0; --i) {
1064 page = (PDFCorePage *)pages->get(i);
1065 if (page->yDest < drawAreaHeight) {
1066 break;
1067 }
1068 }
1069 page = (PDFCorePage *)pages->get(i);
1070 x = page->w - drawAreaWidth;
1071 if (continuousMode) {
1072 y = pageY[page->page - 1] + page->h - drawAreaHeight;
1073 } else {
1074 y = page->h - drawAreaHeight;
1075 }
1076 update(topPage, x, y, zoom, rotate, gFalse, gFalse);
1077}
1078
1079void PDFCore::zoomToRect(int pg, double ulx, double uly,
1080 double lrx, double lry) {
1081 int x0, y0, x1, y1, u, sx, sy;
1082 double rx, ry, newZoom, t;
1083 PDFCorePage *p;
1084
1085 cvtUserToDev(pg, ulx, uly, &x0, &y0);
1086 cvtUserToDev(pg, lrx, lry, &x1, &y1);
1087 if (x0 > x1) {
1088 u = x0; x0 = x1; x1 = u;
1089 }
1090 if (y0 > y1) {
1091 u = y0; y0 = y1; y1 = u;
1092 }
1093 rx = (double)drawAreaWidth / (double)(x1 - x0);
1094 ry = (double)drawAreaHeight / (double)(y1 - y0);
1095 if (rx < ry) {
1096 newZoom = rx * (dpi / (0.01 * 72));
1097 sx = (int)(rx * x0);
1098 t = (drawAreaHeight * (x1 - x0)) / drawAreaWidth;
1099 sy = (int)(rx * (y0 + y1 - t) / 2);
1100 if (continuousMode) {
1101 if ((p = findPage(pg)) && p->w < maxPageW) {
1102 sx += (int)(0.5 * rx * (maxPageW - p->w));
1103 }
1104 u = (pg - 1) * continuousModePageSpacing;
1105 sy += (int)(rx * (pageY[pg - 1] - u)) + u;
1106 }
1107 } else {
1108 newZoom = ry * (dpi / (0.01 * 72));
1109 t = (drawAreaWidth * (y1 - y0)) / drawAreaHeight;
1110 sx = (int)(ry * (x0 + x1 - t) / 2);
1111 sy = (int)(ry * y0);
1112 if (continuousMode) {
1113 if ((p = findPage(pg)) && p->w < maxPageW) {
1114 sx += (int)(0.5 * rx * (maxPageW - p->w));
1115 }
1116 u = (pg - 1) * continuousModePageSpacing;
1117 sy += (int)(ry * (pageY[pg - 1] - u)) + u;
1118 }
1119 }
1120 update(pg, sx, sy, newZoom, rotate, gFalse, gFalse);
1121}
1122
1123void PDFCore::zoomCentered(double zoomA) {
1124 int sx, sy, rot, hAdjust, vAdjust, i;
1125 double dpi1, dpi2, pageW, pageH;
1126 PDFCorePage *page;
1127
1128 if (zoomA == zoomPage) {
1129 if (continuousMode) {
1130 pageW = (rotate == 90 || rotate == 270) ? maxUnscaledPageH
1131 : maxUnscaledPageW;
1132 pageH = (rotate == 90 || rotate == 270) ? maxUnscaledPageW
1133 : maxUnscaledPageH;
1134 dpi1 = 72.0 * (double)drawAreaWidth / pageW;
1135 dpi2 = 72.0 * (double)(drawAreaHeight - continuousModePageSpacing) /
1136 pageH;
1137 if (dpi2 < dpi1) {
1138 dpi1 = dpi2;
1139 }
1140 } else {
1141 // in single-page mode, sx=sy=0 -- so dpi1 is irrelevant
1142 dpi1 = dpi;
1143 }
1144 sx = 0;
1145
1146 } else if (zoomA == zoomWidth) {
1147 if (continuousMode) {
1148 pageW = (rotate == 90 || rotate == 270) ? maxUnscaledPageH
1149 : maxUnscaledPageW;
1150 } else {
1151 rot = rotate + doc->getPageRotate(topPage);
1152 if (rot >= 360) {
1153 rot -= 360;
1154 } else if (rot < 0) {
1155 rot += 360;
1156 }
1157 pageW = (rot == 90 || rot == 270) ? doc->getPageCropHeight(topPage)
1158 : doc->getPageCropWidth(topPage);
1159 }
1160 dpi1 = 72.0 * (double)drawAreaWidth / pageW;
1161 sx = 0;
1162
1163 } else if (zoomA <= 0) {
1164 return;
1165
1166 } else {
1167 dpi1 = 72.0 * zoomA / 100.0;
1168 if ((page = (PDFCorePage *)pages->get(0)) && page->xDest > 0) {
1169 hAdjust = page->xDest;
1170 } else {
1171 hAdjust = 0;
1172 }
1173 sx = (int)((scrollX - hAdjust + drawAreaWidth / 2) * (dpi1 / dpi)) -
1174 drawAreaWidth / 2;
1175 if (sx < 0) {
1176 sx = 0;
1177 }
1178 }
1179
1180 if (continuousMode) {
1181 // we can't just multiply scrollY by dpi1/dpi -- the rounding
1182 // errors add up (because the pageY values are integers) -- so
1183 // we compute the pageY values at the new zoom level instead
1184 sy = 0;
1185 for (i = 1; i < topPage; ++i) {
1186 rot = rotate + doc->getPageRotate(i);
1187 if (rot >= 360) {
1188 rot -= 360;
1189 } else if (rot < 0) {
1190 rot += 360;
1191 }
1192 if (rot == 90 || rot == 270) {
1193 sy += (int)((doc->getPageCropWidth(i) * dpi1) / 72 + 0.5);
1194 } else {
1195 sy += (int)((doc->getPageCropHeight(i) * dpi1) / 72 + 0.5);
1196 }
1197 }
1198 vAdjust = (topPage - 1) * continuousModePageSpacing;
1199 sy = sy + (int)((scrollY - pageY[topPage - 1] + drawAreaHeight / 2)
1200 * (dpi1 / dpi))
1201 + vAdjust - drawAreaHeight / 2;
1202 } else {
1203 sy = (int)((scrollY + drawAreaHeight / 2) * (dpi1 / dpi))
1204 - drawAreaHeight / 2;
1205 }
1206
1207 update(topPage, sx, sy, zoomA, rotate, gFalse, gFalse);
1208}
1209
1210// Zoom so that the current page(s) fill the window width. Maintain
1211// the vertical center.
1212void PDFCore::zoomToCurrentWidth() {
1213 double w, maxW, dpi1;
1214 int sx, sy, vAdjust, rot, i;
1215
1216 // compute the maximum page width of visible pages
1217 rot = rotate + doc->getPageRotate(topPage);
1218 if (rot >= 360) {
1219 rot -= 360;
1220 } else if (rot < 0) {
1221 rot += 360;
1222 }
1223 if (rot == 90 || rot == 270) {
1224 maxW = doc->getPageCropHeight(topPage);
1225 } else {
1226 maxW = doc->getPageCropWidth(topPage);
1227 }
1228 if (continuousMode) {
1229 for (i = topPage + 1;
1230 i < doc->getNumPages() && pageY[i-1] < scrollY + drawAreaHeight;
1231 ++i) {
1232 rot = rotate + doc->getPageRotate(i);
1233 if (rot >= 360) {
1234 rot -= 360;
1235 } else if (rot < 0) {
1236 rot += 360;
1237 }
1238 if (rot == 90 || rot == 270) {
1239 w = doc->getPageCropHeight(i);
1240 } else {
1241 w = doc->getPageCropWidth(i);
1242 }
1243 if (w > maxW) {
1244 maxW = w;
1245 }
1246 }
1247 }
1248
1249 // compute the resolution
1250 dpi1 = (drawAreaWidth / maxW) * 72;
1251
1252 // compute the horizontal scroll position
1253 if (continuousMode) {
1254 sx = ((int)(maxPageW * dpi1 / dpi) - drawAreaWidth) / 2;
1255 } else {
1256 sx = 0;
1257 }
1258
1259 // compute the vertical scroll position
1260 if (continuousMode) {
1261 // we can't just multiply scrollY by dpi1/dpi -- the rounding
1262 // errors add up (because the pageY values are integers) -- so
1263 // we compute the pageY values at the new zoom level instead
1264 sy = 0;
1265 for (i = 1; i < topPage; ++i) {
1266 rot = rotate + doc->getPageRotate(i);
1267 if (rot >= 360) {
1268 rot -= 360;
1269 } else if (rot < 0) {
1270 rot += 360;
1271 }
1272 if (rot == 90 || rot == 270) {
1273 sy += (int)((doc->getPageCropWidth(i) * dpi1) / 72 + 0.5);
1274 } else {
1275 sy += (int)((doc->getPageCropHeight(i) * dpi1) / 72 + 0.5);
1276 }
1277 }
1278 vAdjust = (topPage - 1) * continuousModePageSpacing;
1279 sy = sy + (int)((scrollY - pageY[topPage - 1] + drawAreaHeight / 2)
1280 * (dpi1 / dpi))
1281 + vAdjust - drawAreaHeight / 2;
1282 } else {
1283 sy = (int)((scrollY + drawAreaHeight / 2) * (dpi1 / dpi))
1284 - drawAreaHeight / 2;
1285 }
1286
1287 update(topPage, sx, sy, (dpi1 * 100) / 72, rotate, gFalse, gFalse);
1288}
1289
1290void PDFCore::setContinuousMode(GBool cm) {
1291 if (continuousMode != cm) {
1292 continuousMode = cm;
1293 update(topPage, scrollX, -1, zoom, rotate, gTrue, gFalse);
1294 }
1295}
1296
1297void PDFCore::setSelection(int newSelectPage,
1298 int newSelectULX, int newSelectULY,
1299 int newSelectLRX, int newSelectLRY) {
1300 int x0, y0, x1, y1, py;
1301 GBool haveSel, newHaveSel;
1302 GBool needRedraw, needScroll;
1303 GBool moveLeft, moveRight, moveTop, moveBottom;
1304 SplashColor xorColor;
1305 PDFCorePage *page;
1306
1307
1308 haveSel = selectULX != selectLRX && selectULY != selectLRY;
1309 newHaveSel = newSelectULX != newSelectLRX && newSelectULY != newSelectLRY;
1310
1311 // erase old selection on off-screen bitmap
1312 needRedraw = gFalse;
1313 if (haveSel) {
1314 xorColor[0] = xorColor[1] = xorColor[2] = 0xff;
1315 xorRectangle(selectPage, selectULX, selectULY, selectLRX, selectLRY,
1316 new SplashSolidColor(xorColor));
1317 needRedraw = gTrue;
1318 }
1319
1320 // draw new selection on off-screen bitmap
1321 if (newHaveSel) {
1322 xorColor[0] = xorColor[1] = xorColor[2] = 0xff;
1323 xorRectangle(newSelectPage, newSelectULX, newSelectULY,
1324 newSelectLRX, newSelectLRY,
1325 new SplashSolidColor(xorColor));
1326 needRedraw = gTrue;
1327 }
1328
1329 // check which edges moved
1330 if (!haveSel || newSelectPage != selectPage) {
1331 moveLeft = moveTop = moveRight = moveBottom = gTrue;
1332 } else {
1333 moveLeft = newSelectULX != selectULX;
1334 moveTop = newSelectULY != selectULY;
1335 moveRight = newSelectLRX != selectLRX;
1336 moveBottom = newSelectLRY != selectLRY;
1337 }
1338
1339 // redraw currently visible part of bitmap
1340 if (needRedraw) {
1341 if (!haveSel) {
1342 page = findPage(newSelectPage);
1343 x0 = newSelectULX;
1344 y0 = newSelectULY;
1345 x1 = newSelectLRX;
1346 y1 = newSelectLRY;
1347 redrawWindow(page->xDest + x0, page->yDest + y0,
1348 x1 - x0 + 1, y1 - y0 + 1, gFalse);
1349 } else if (!newHaveSel) {
1350 if ((page = findPage(selectPage))) {
1351 x0 = selectULX;
1352 y0 = selectULY;
1353 x1 = selectLRX;
1354 y1 = selectLRY;
1355 redrawWindow(page->xDest + x0, page->yDest + y0,
1356 x1 - x0 + 1, y1 - y0 + 1, gFalse);
1357 }
1358 } else {
1359 page = findPage(newSelectPage);
1360 if (moveLeft) {
1361 x0 = newSelectULX < selectULX ? newSelectULX : selectULX;
1362 y0 = newSelectULY < selectULY ? newSelectULY : selectULY;
1363 x1 = newSelectULX > selectULX ? newSelectULX : selectULX;
1364 y1 = newSelectLRY > selectLRY ? newSelectLRY : selectLRY;
1365 redrawWindow(page->xDest + x0, page->yDest + y0,
1366 x1 - x0 + 1, y1 - y0 + 1, gFalse);
1367 }
1368 if (moveRight) {
1369 x0 = newSelectLRX < selectLRX ? newSelectLRX : selectLRX;
1370 y0 = newSelectULY < selectULY ? newSelectULY : selectULY;
1371 x1 = newSelectLRX > selectLRX ? newSelectLRX : selectLRX;
1372 y1 = newSelectLRY > selectLRY ? newSelectLRY : selectLRY;
1373 redrawWindow(page->xDest + x0, page->yDest + y0,
1374 x1 - x0 + 1, y1 - y0 + 1, gFalse);
1375 }
1376 if (moveTop) {
1377 x0 = newSelectULX < selectULX ? newSelectULX : selectULX;
1378 y0 = newSelectULY < selectULY ? newSelectULY : selectULY;
1379 x1 = newSelectLRX > selectLRX ? newSelectLRX : selectLRX;
1380 y1 = newSelectULY > selectULY ? newSelectULY : selectULY;
1381 redrawWindow(page->xDest + x0, page->yDest + y0,
1382 x1 - x0 + 1, y1 - y0 + 1, gFalse);
1383 }
1384 if (moveBottom) {
1385 x0 = newSelectULX < selectULX ? newSelectULX : selectULX;
1386 y0 = newSelectLRY < selectLRY ? newSelectLRY : selectLRY;
1387 x1 = newSelectLRX > selectLRX ? newSelectLRX : selectLRX;
1388 y1 = newSelectLRY > selectLRY ? newSelectLRY : selectLRY;
1389 redrawWindow(page->xDest + x0, page->yDest + y0,
1390 x1 - x0 + 1, y1 - y0 + 1, gFalse);
1391 }
1392 }
1393 }
1394
1395 // switch to new selection coords
1396 selectPage = newSelectPage;
1397 selectULX = newSelectULX;
1398 selectULY = newSelectULY;
1399 selectLRX = newSelectLRX;
1400 selectLRY = newSelectLRY;
1401
1402 // scroll if necessary
1403 if (newHaveSel) {
1404 page = findPage(selectPage);
1405 needScroll = gFalse;
1406 x0 = scrollX;
1407 y0 = scrollY;
1408 if (moveLeft && page->xDest + selectULX < 0) {
1409 x0 += page->xDest + selectULX;
1410 needScroll = gTrue;
1411 } else if (moveRight && page->xDest + selectLRX >= drawAreaWidth) {
1412 x0 += page->xDest + selectLRX - drawAreaWidth;
1413 needScroll = gTrue;
1414 } else if (moveLeft && page->xDest + selectULX >= drawAreaWidth) {
1415 x0 += page->xDest + selectULX - drawAreaWidth;
1416 needScroll = gTrue;
1417 } else if (moveRight && page->xDest + selectLRX < 0) {
1418 x0 += page->xDest + selectLRX;
1419 needScroll = gTrue;
1420 }
1421 py = continuousMode ? pageY[selectPage - 1] : 0;
1422 if (moveTop && py + selectULY < y0) {
1423 y0 = py + selectULY;
1424 needScroll = gTrue;
1425 } else if (moveBottom && py + selectLRY >= y0 + drawAreaHeight) {
1426 y0 = py + selectLRY - drawAreaHeight;
1427 needScroll = gTrue;
1428 } else if (moveTop && py + selectULY >= y0 + drawAreaHeight) {
1429 y0 = py + selectULY - drawAreaHeight;
1430 needScroll = gTrue;
1431 } else if (moveBottom && py + selectLRY < y0) {
1432 y0 = py + selectLRY;
1433 needScroll = gTrue;
1434 }
1435 if (needScroll) {
1436 scrollTo(x0, y0);
1437 }
1438 }
1439}
1440
1441void PDFCore::moveSelection(int pg, int x, int y) {
1442 int newSelectULX, newSelectULY, newSelectLRX, newSelectLRY;
1443
1444 // don't allow selections to span multiple pages
1445 if (pg != selectPage) {
1446 return;
1447 }
1448
1449 // move appropriate edges of selection
1450 if (lastDragLeft) {
1451 if (x < selectLRX) {
1452 newSelectULX = x;
1453 newSelectLRX = selectLRX;
1454 } else {
1455 newSelectULX = selectLRX;
1456 newSelectLRX = x;
1457 lastDragLeft = gFalse;
1458 }
1459 } else {
1460 if (x > selectULX) {
1461 newSelectULX = selectULX;
1462 newSelectLRX = x;
1463 } else {
1464 newSelectULX = x;
1465 newSelectLRX = selectULX;
1466 lastDragLeft = gTrue;
1467 }
1468 }
1469 if (lastDragTop) {
1470 if (y < selectLRY) {
1471 newSelectULY = y;
1472 newSelectLRY = selectLRY;
1473 } else {
1474 newSelectULY = selectLRY;
1475 newSelectLRY = y;
1476 lastDragTop = gFalse;
1477 }
1478 } else {
1479 if (y > selectULY) {
1480 newSelectULY = selectULY;
1481 newSelectLRY = y;
1482 } else {
1483 newSelectULY = y;
1484 newSelectLRY = selectULY;
1485 lastDragTop = gTrue;
1486 }
1487 }
1488
1489 // redraw the selection
1490 setSelection(selectPage, newSelectULX, newSelectULY,
1491 newSelectLRX, newSelectLRY);
1492}
1493
1494void PDFCore::xorRectangle(int pg, int x0, int y0, int x1, int y1,
1495 SplashPattern *pattern, PDFCoreTile *oneTile) {
1496 Splash *splash;
1497 SplashPath *path;
1498 PDFCorePage *page;
1499 PDFCoreTile *tile;
1500 SplashCoord xx0, yy0, xx1, yy1;
1501 int xi, yi, wi, hi;
1502 int i;
1503
1504 if ((page = findPage(pg))) {
1505 for (i = 0; i < page->tiles->getLength(); ++i) {
1506 tile = (PDFCoreTile *)page->tiles->get(i);
1507 if (!oneTile || tile == oneTile) {
1508 splash = new Splash(tile->bitmap, gFalse);
1509 splash->setFillPattern(pattern->copy());
1510 xx0 = (SplashCoord)(x0 - tile->xMin);
1511 yy0 = (SplashCoord)(y0 - tile->yMin);
1512 xx1 = (SplashCoord)(x1 - tile->xMin);
1513 yy1 = (SplashCoord)(y1 - tile->yMin);
1514 path = new SplashPath();
1515 path->moveTo(xx0, yy0);
1516 path->lineTo(xx1, yy0);
1517 path->lineTo(xx1, yy1);
1518 path->lineTo(xx0, yy1);
1519 path->close();
1520 splash->xorFill(path, gTrue);
1521 delete path;
1522 delete splash;
1523 xi = x0 - tile->xMin;
1524 wi = x1 - x0;
1525 if (xi < 0) {
1526 wi += xi;
1527 xi = 0;
1528 }
1529 if (xi + wi > tile->bitmap->getWidth()) {
1530 wi = tile->bitmap->getWidth() - xi;
1531 }
1532 yi = y0 - tile->yMin;
1533 hi = y1 - y0;
1534 if (yi < 0) {
1535 hi += yi;
1536 yi = 0;
1537 }
1538 if (yi + hi > tile->bitmap->getHeight()) {
1539 hi = tile->bitmap->getHeight() - yi;
1540 }
1541 updateTileData(tile, xi, yi, wi, hi, gTrue);
1542 }
1543 }
1544 }
1545 delete pattern;
1546}
1547
1548GBool PDFCore::getSelection(int *pg, double *ulx, double *uly,
1549 double *lrx, double *lry) {
1550 if (selectULX == selectLRX || selectULY == selectLRY) {
1551 return gFalse;
1552 }
1553 *pg = selectPage;
1554 cvtDevToUser(selectPage, selectULX, selectULY, ulx, uly);
1555 cvtDevToUser(selectPage, selectLRX, selectLRY, lrx, lry);
1556 return gTrue;
1557}
1558
1559GString *PDFCore::extractText(int pg, double xMin, double yMin,
1560 double xMax, double yMax) {
1561 PDFCorePage *page;
1562 TextOutputDev *textOut;
1563 int x0, y0, x1, y1, t;
1564 GString *s;
1565
1566 if (!doc->okToCopy()) {
1567 return NULL;
1568 }
1569 if ((page = findPage(pg))) {
1570 cvtUserToDev(pg, xMin, yMin, &x0, &y0);
1571 cvtUserToDev(pg, xMax, yMax, &x1, &y1);
1572 if (x0 > x1) {
1573 t = x0; x0 = x1; x1 = t;
1574 }
1575 if (y0 > y1) {
1576 t = y0; y0 = y1; y1 = t;
1577 }
1578 s = page->text->getText(x0, y0, x1, y1);
1579 } else {
1580 textOut = new TextOutputDev(NULL, gTrue, gFalse, gFalse);
1581 if (textOut->isOk()) {
1582 doc->displayPage(textOut, pg, dpi, dpi, rotate, gFalse, gTrue, gFalse);
1583 textOut->cvtUserToDev(xMin, yMin, &x0, &y0);
1584 textOut->cvtUserToDev(xMax, yMax, &x1, &y1);
1585 if (x0 > x1) {
1586 t = x0; x0 = x1; x1 = t;
1587 }
1588 if (y0 > y1) {
1589 t = y0; y0 = y1; y1 = t;
1590 }
1591 s = textOut->getText(x0, y0, x1, y1);
1592 } else {
1593 s = new GString();
1594 }
1595 delete textOut;
1596 }
1597 return s;
1598}
1599
1600GBool PDFCore::find(char *s, GBool caseSensitive, GBool next, GBool backward,
1601 GBool onePageOnly) {
1602 Unicode *u;
1603 int len, i;
1604 GBool ret;
1605
1606 // convert to Unicode
1607 len = strlen(s);
1608 u = (Unicode *)gmallocn(len, sizeof(Unicode));
1609 for (i = 0; i < len; ++i) {
1610 u[i] = (Unicode)(s[i] & 0xff);
1611 }
1612
1613 ret = findU(u, len, caseSensitive, next, backward, onePageOnly);
1614
1615 gfree(u);
1616 return ret;
1617}
1618
1619GBool PDFCore::findU(Unicode *u, int len, GBool caseSensitive,
1620 GBool next, GBool backward, GBool onePageOnly) {
1621 TextOutputDev *textOut;
1622 double xMin, yMin, xMax, yMax;
1623 PDFCorePage *page;
1624 PDFCoreTile *tile;
1625 int pg;
1626 GBool startAtTop, startAtLast, stopAtLast;
1627
1628 // check for zero-length string
1629 if (len == 0) {
1630 return gFalse;
1631 }
1632
1633 setBusyCursor(gTrue);
1634
1635 // search current page starting at previous result, current
1636 // selection, or top/bottom of page
1637 startAtTop = startAtLast = gFalse;
1638 xMin = yMin = xMax = yMax = 0;
1639 pg = topPage;
1640 if (next) {
1641 startAtLast = gTrue;
1642 } else if (selectULX != selectLRX && selectULY != selectLRY) {
1643 pg = selectPage;
1644 if (backward) {
1645 xMin = selectULX - 1;
1646 yMin = selectULY - 1;
1647 } else {
1648 xMin = selectULX + 1;
1649 yMin = selectULY + 1;
1650 }
1651 } else {
1652 startAtTop = gTrue;
1653 }
1654 if (!(page = findPage(pg))) {
1655 displayPage(pg, zoom, rotate, gTrue, gFalse);
1656 page = findPage(pg);
1657 }
1658 if (page->text->findText(u, len, startAtTop, gTrue, startAtLast, gFalse,
1659 caseSensitive, backward,
1660 &xMin, &yMin, &xMax, &yMax)) {
1661 goto found;
1662 }
1663
1664 if (!onePageOnly) {
1665
1666 // search following/previous pages
1667 textOut = new TextOutputDev(NULL, gTrue, gFalse, gFalse);
1668 if (!textOut->isOk()) {
1669 delete textOut;
1670 goto notFound;
1671 }
1672 for (pg = backward ? pg - 1 : pg + 1;
1673 backward ? pg >= 1 : pg <= doc->getNumPages();
1674 pg += backward ? -1 : 1) {
1675 doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse);
1676 if (textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse,
1677 caseSensitive, backward,
1678 &xMin, &yMin, &xMax, &yMax)) {
1679 delete textOut;
1680 goto foundPage;
1681 }
1682 }
1683
1684 // search previous/following pages
1685 for (pg = backward ? doc->getNumPages() : 1;
1686 backward ? pg > topPage : pg < topPage;
1687 pg += backward ? -1 : 1) {
1688 doc->displayPage(textOut, pg, 72, 72, 0, gFalse, gTrue, gFalse);
1689 if (textOut->findText(u, len, gTrue, gTrue, gFalse, gFalse,
1690 caseSensitive, backward,
1691 &xMin, &yMin, &xMax, &yMax)) {
1692 delete textOut;
1693 goto foundPage;
1694 }
1695 }
1696 delete textOut;
1697
1698 }
1699
1700 // search current page ending at previous result, current selection,
1701 // or bottom/top of page
1702 if (!startAtTop) {
1703 xMin = yMin = xMax = yMax = 0;
1704 if (next) {
1705 stopAtLast = gTrue;
1706 } else {
1707 stopAtLast = gFalse;
1708 xMax = selectLRX;
1709 yMax = selectLRY;
1710 }
1711 if (page->text->findText(u, len, gTrue, gFalse, gFalse, stopAtLast,
1712 caseSensitive, backward,
1713 &xMin, &yMin, &xMax, &yMax)) {
1714 goto found;
1715 }
1716 }
1717
1718 // not found
1719 notFound:
1720 setBusyCursor(gFalse);
1721 return gFalse;
1722
1723 // found on a different page
1724 foundPage:
1725 update(pg, scrollX, continuousMode ? -1 : 0, zoom, rotate, gFalse, gTrue);
1726 page = findPage(pg);
1727 if (!page->text->findText(u, len, gTrue, gTrue, gFalse, gFalse,
1728 caseSensitive, backward,
1729 &xMin, &yMin, &xMax, &yMax)) {
1730 // this can happen if coalescing is bad
1731 goto notFound;
1732 }
1733
1734 // found: change the selection
1735 found:
1736 tile = (PDFCoreTile *)page->tiles->get(0);
1737 setSelection(pg, (int)floor(xMin), (int)floor(yMin),
1738 (int)ceil(xMax), (int)ceil(yMax));
1739
1740 setBusyCursor(gFalse);
1741 return gTrue;
1742}
1743
1744
1745GBool PDFCore::cvtWindowToUser(int xw, int yw,
1746 int *pg, double *xu, double *yu) {
1747 PDFCorePage *page;
1748 PDFCoreTile *tile;
1749 int i;
1750
1751 for (i = 0; i < pages->getLength(); ++i) {
1752 page = (PDFCorePage *)pages->get(i);
1753 if (xw >= page->xDest && xw < page->xDest + page->w &&
1754 yw >= page->yDest && yw < page->yDest + page->h) {
1755 tile = (PDFCoreTile *)page->tiles->get(0);
1756 *pg = page->page;
1757 xw -= tile->xDest;
1758 yw -= tile->yDest;
1759 *xu = tile->ictm[0] * xw + tile->ictm[2] * yw + tile->ictm[4];
1760 *yu = tile->ictm[1] * xw + tile->ictm[3] * yw + tile->ictm[5];
1761 return gTrue;
1762 }
1763 }
1764 *pg = 0;
1765 *xu = *yu = 0;
1766 return gFalse;
1767}
1768
1769GBool PDFCore::cvtWindowToDev(int xw, int yw, int *pg, int *xd, int *yd) {
1770 PDFCorePage *page;
1771 int i;
1772
1773 for (i = 0; i < pages->getLength(); ++i) {
1774 page = (PDFCorePage *)pages->get(i);
1775 if (xw >= page->xDest && xw < page->xDest + page->w &&
1776 yw >= page->yDest && yw < page->yDest + page->h) {
1777 *pg = page->page;
1778 *xd = xw - page->xDest;
1779 *yd = yw - page->yDest;
1780 return gTrue;
1781 }
1782 }
1783 *pg = 0;
1784 *xd = *yd = 0;
1785 return gFalse;
1786}
1787
1788void PDFCore::cvtUserToWindow(int pg, double xu, double yu, int *xw, int *yw) {
1789 PDFCorePage *page;
1790 PDFCoreTile *tile;
1791
1792 if ((page = findPage(pg)) &&
1793 page->tiles->getLength() > 0) {
1794 tile = (PDFCoreTile *)page->tiles->get(0);
1795 } else if (curTile && curPage->page == pg) {
1796 tile = curTile;
1797 } else {
1798 tile = NULL;
1799 }
1800 if (tile) {
1801 *xw = tile->xDest + (int)(tile->ctm[0] * xu + tile->ctm[2] * yu +
1802 tile->ctm[4] + 0.5);
1803 *yw = tile->yDest + (int)(tile->ctm[1] * xu + tile->ctm[3] * yu +
1804 tile->ctm[5] + 0.5);
1805 } else {
1806 // this should never happen
1807 *xw = *yw = 0;
1808 }
1809}
1810
1811void PDFCore::cvtUserToDev(int pg, double xu, double yu, int *xd, int *yd) {
1812 PDFCorePage *page;
1813 PDFCoreTile *tile;
1814 double ctm[6];
1815
1816 if ((page = findPage(pg)) &&
1817 page->tiles->getLength() > 0) {
1818 tile = (PDFCoreTile *)page->tiles->get(0);
1819 } else if (curTile && curPage->page == pg) {
1820 tile = curTile;
1821 } else {
1822 tile = NULL;
1823 }
1824 if (tile) {
1825 *xd = (int)(tile->xMin + tile->ctm[0] * xu +
1826 tile->ctm[2] * yu + tile->ctm[4] + 0.5);
1827 *yd = (int)(tile->yMin + tile->ctm[1] * xu +
1828 tile->ctm[3] * yu + tile->ctm[5] + 0.5);
1829 } else {
1830 doc->getCatalog()->getPage(pg)->getDefaultCTM(ctm, dpi, dpi, rotate,
1831 gFalse, out->upsideDown());
1832 *xd = (int)(ctm[0] * xu + ctm[2] * yu + ctm[4] + 0.5);
1833 *yd = (int)(ctm[1] * xu + ctm[3] * yu + ctm[5] + 0.5);
1834 }
1835}
1836
1837void PDFCore::cvtDevToWindow(int pg, int xd, int yd, int *xw, int *yw) {
1838 PDFCorePage *page;
1839
1840 if ((page = findPage(pg))) {
1841 *xw = page->xDest + xd;
1842 *yw = page->yDest + yd;
1843 } else {
1844 // this should never happen
1845 *xw = *yw = 0;
1846 }
1847}
1848
1849void PDFCore::cvtDevToUser(int pg, int xd, int yd, double *xu, double *yu) {
1850 PDFCorePage *page;
1851 PDFCoreTile *tile;
1852
1853 if ((page = findPage(pg)) &&
1854 page->tiles->getLength() > 0) {
1855 tile = (PDFCoreTile *)page->tiles->get(0);
1856 } else if (curTile && curPage->page == pg) {
1857 tile = curTile;
1858 } else {
1859 tile = NULL;
1860 }
1861 if (tile) {
1862 xd -= tile->xMin;
1863 yd -= tile->yMin;
1864 *xu = tile->ictm[0] * xd + tile->ictm[2] * yd + tile->ictm[4];
1865 *yu = tile->ictm[1] * xd + tile->ictm[3] * yd + tile->ictm[5];
1866 } else {
1867 // this should never happen
1868 *xu = *yu = 0;
1869 }
1870}
1871
1872void PDFCore::setReverseVideo(GBool reverseVideoA) {
1873 out->setReverseVideo(reverseVideoA);
1874 update(topPage, scrollX, scrollY, zoom, rotate, gTrue, gFalse);
1875}
1876
1877LinkAction *PDFCore::findLink(int pg, double x, double y) {
1878 PDFCorePage *page;
1879
1880 if ((page = findPage(pg))) {
1881 return page->links ? page->links->find(x, y) : (LinkAction *)NULL;
1882 }
1883 return NULL;
1884}
1885
1886PDFCorePage *PDFCore::findPage(int pg) {
1887 PDFCorePage *page;
1888 int i;
1889
1890 for (i = 0; i < pages->getLength(); ++i) {
1891 page = (PDFCorePage *)pages->get(i);
1892 if (page->page == pg) {
1893 return page;
1894 }
1895 }
1896 return NULL;
1897}
1898
1899void PDFCore::redrawCbk(void *data, int x0, int y0, int x1, int y1,
1900 GBool composited) {
1901 PDFCore *core = (PDFCore *)data;
1902
1903 core->curTile->bitmap = core->out->getBitmap();
1904
1905 // the default CTM is set by the Gfx constructor; tile->ctm is
1906 // needed by the coordinate conversion functions (which may be
1907 // called during redraw)
1908 memcpy(core->curTile->ctm, core->out->getDefCTM(), 6 * sizeof(double));
1909 memcpy(core->curTile->ictm, core->out->getDefICTM(), 6 * sizeof(double));
1910
1911 // the bitmap created by Gfx and SplashOutputDev can be a slightly
1912 // different size due to rounding errors
1913 if (x1 >= core->curTile->xMax) {
1914 x1 = core->curTile->xMax - 1;
1915 }
1916 if (y1 >= core->curTile->yMax) {
1917 y1 = core->curTile->yMax - 1;
1918 }
1919
1920 core->clippedRedrawRect(core->curTile, x0, y0,
1921 core->curTile->xDest + x0, core->curTile->yDest + y0,
1922 x1 - x0 + 1, y1 - y0 + 1,
1923 0, 0, core->drawAreaWidth, core->drawAreaHeight,
1924 gTrue, composited);
1925}
1926
1927void PDFCore::redrawWindow(int x, int y, int width, int height,
1928 GBool needUpdate) {
1929 PDFCorePage *page;
1930 PDFCoreTile *tile;
1931 int xDest, yDest, w, i, j;
1932
1933 if (pages->getLength() == 0) {
1934 redrawRect(NULL, 0, 0, x, y, width, height, gTrue);
1935 return;
1936 }
1937
1938 for (i = 0; i < pages->getLength(); ++i) {
1939 page = (PDFCorePage *)pages->get(i);
1940 for (j = 0; j < page->tiles->getLength(); ++j) {
1941 tile = (PDFCoreTile *)page->tiles->get(j);
1942 if (tile->edges & pdfCoreTileTopEdge) {
1943 if (tile->edges & pdfCoreTileLeftEdge) {
1944 xDest = 0;
1945 } else {
1946 xDest = tile->xDest;
1947 }
1948 if (tile->edges & pdfCoreTileRightEdge) {
1949 w = drawAreaWidth - xDest;
1950 } else {
1951 w = tile->xDest + (tile->xMax - tile->xMin) - xDest;
1952 }
1953 clippedRedrawRect(NULL, 0, 0,
1954 xDest, 0, w, tile->yDest,
1955 x, y, width, height, gFalse);
1956 }
1957 if (tile->edges & pdfCoreTileBottomEdge) {
1958 if (tile->edges & pdfCoreTileLeftEdge) {
1959 xDest = 0;
1960 } else {
1961 xDest = tile->xDest;
1962 }
1963 if (tile->edges & pdfCoreTileRightEdge) {
1964 w = drawAreaWidth - xDest;
1965 } else {
1966 w = tile->xDest + (tile->xMax - tile->xMin) - xDest;
1967 }
1968 yDest = tile->yDest + (tile->yMax - tile->yMin);
1969 clippedRedrawRect(NULL, 0, 0,
1970 xDest, yDest, w, drawAreaHeight - yDest,
1971 x, y, width, height, gFalse);
1972 } else if ((tile->edges & pdfCoreTileBottomSpace) &&
1973 i+1 < pages->getLength()) {
1974 if (tile->edges & pdfCoreTileLeftEdge) {
1975 xDest = 0;
1976 } else {
1977 xDest = tile->xDest;
1978 }
1979 if (tile->edges & pdfCoreTileRightEdge) {
1980 w = drawAreaWidth - xDest;
1981 } else {
1982 w = tile->xDest + (tile->xMax - tile->xMin) - xDest;
1983 }
1984 yDest = tile->yDest + (tile->yMax - tile->yMin);
1985 clippedRedrawRect(NULL, 0, 0,
1986 xDest, yDest,
1987 w, ((PDFCorePage *)pages->get(i+1))->yDest - yDest,
1988 x, y, width, height, gFalse);
1989 }
1990 if (tile->edges & pdfCoreTileLeftEdge) {
1991 clippedRedrawRect(NULL, 0, 0,
1992 0, tile->yDest,
1993 tile->xDest, tile->yMax - tile->yMin,
1994 x, y, width, height, gFalse);
1995 }
1996 if (tile->edges & pdfCoreTileRightEdge) {
1997 xDest = tile->xDest + (tile->xMax - tile->xMin);
1998 clippedRedrawRect(NULL, 0, 0,
1999 xDest, tile->yDest,
2000 drawAreaWidth - xDest, tile->yMax - tile->yMin,
2001 x, y, width, height, gFalse);
2002 }
2003 clippedRedrawRect(tile, 0, 0, tile->xDest, tile->yDest,
2004 tile->bitmap->getWidth(), tile->bitmap->getHeight(),
2005 x, y, width, height, needUpdate);
2006 }
2007 }
2008}
2009
2010PDFCoreTile *PDFCore::newTile(int xDestA, int yDestA) {
2011 return new PDFCoreTile(xDestA, yDestA);
2012}
2013
2014void PDFCore::updateTileData(PDFCoreTile *tileA, int xSrc, int ySrc,
2015 int width, int height, GBool composited) {
2016}
2017
2018void PDFCore::clippedRedrawRect(PDFCoreTile *tile, int xSrc, int ySrc,
2019 int xDest, int yDest, int width, int height,
2020 int xClip, int yClip, int wClip, int hClip,
2021 GBool needUpdate, GBool composited) {
2022 if (tile && needUpdate) {
2023 updateTileData(tile, xSrc, ySrc, width, height, composited);
2024 }
2025 if (xDest < xClip) {
2026 xSrc += xClip - xDest;
2027 width -= xClip - xDest;
2028 xDest = xClip;
2029 }
2030 if (xDest + width > xClip + wClip) {
2031 width = xClip + wClip - xDest;
2032 }
2033 if (yDest < yClip) {
2034 ySrc += yClip - yDest;
2035 height -= yClip - yDest;
2036 yDest = yClip;
2037 }
2038 if (yDest + height > yClip + hClip) {
2039 height = yClip + hClip - yDest;
2040 }
2041 if (width > 0 && height > 0) {
2042 redrawRect(tile, xSrc, ySrc, xDest, yDest, width, height, composited);
2043 }
2044}
02045
=== added file '.pc/02_permissions.dpatch/xpdf/XPDFCore.cc'
--- .pc/02_permissions.dpatch/xpdf/XPDFCore.cc 1970-01-01 00:00:00 +0000
+++ .pc/02_permissions.dpatch/xpdf/XPDFCore.cc 2010-04-06 13:42:20 +0000
@@ -0,0 +1,1655 @@
1//========================================================================
2//
3// XPDFCore.cc
4//
5// Copyright 2002-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
9#include <aconf.h>
10
11#ifdef USE_GCC_PRAGMAS
12#pragma implementation
13#endif
14
15#include <X11/keysym.h>
16#include <X11/cursorfont.h>
17#include <string.h>
18#include "gmem.h"
19#include "GString.h"
20#include "GList.h"
21#include "Error.h"
22#include "GlobalParams.h"
23#include "PDFDoc.h"
24#include "Link.h"
25#include "ErrorCodes.h"
26#include "GfxState.h"
27#include "CoreOutputDev.h"
28#include "PSOutputDev.h"
29#include "TextOutputDev.h"
30#include "SplashBitmap.h"
31#include "SplashPattern.h"
32#include "XPDFApp.h"
33#include "XPDFCore.h"
34
35// these macro defns conflict with xpdf's Object class
36#ifdef LESSTIF_VERSION
37#undef XtDisplay
38#undef XtScreen
39#undef XtWindow
40#undef XtParent
41#undef XtIsRealized
42#endif
43
44//------------------------------------------------------------------------
45
46// Divide a 16-bit value (in [0, 255*255]) by 255, returning an 8-bit result.
47static inline Guchar div255(int x) {
48 return (Guchar)((x + (x >> 8) + 0x80) >> 8);
49}
50
51//------------------------------------------------------------------------
52
53GString *XPDFCore::currentSelection = NULL;
54XPDFCore *XPDFCore::currentSelectionOwner = NULL;
55Atom XPDFCore::targetsAtom;
56
57//------------------------------------------------------------------------
58// XPDFCoreTile
59//------------------------------------------------------------------------
60
61class XPDFCoreTile: public PDFCoreTile {
62public:
63 XPDFCoreTile(int xDestA, int yDestA);
64 virtual ~XPDFCoreTile();
65 XImage *image;
66};
67
68XPDFCoreTile::XPDFCoreTile(int xDestA, int yDestA):
69 PDFCoreTile(xDestA, yDestA)
70{
71 image = NULL;
72}
73
74XPDFCoreTile::~XPDFCoreTile() {
75 if (image) {
76 gfree(image->data);
77 image->data = NULL;
78 XDestroyImage(image);
79 }
80}
81
82//------------------------------------------------------------------------
83// XPDFCore
84//------------------------------------------------------------------------
85
86XPDFCore::XPDFCore(Widget shellA, Widget parentWidgetA,
87 SplashColorPtr paperColorA, Gulong paperPixelA,
88 Gulong mattePixelA, GBool fullScreenA, GBool reverseVideoA,
89 GBool installCmap, int rgbCubeSizeA):
90 PDFCore(splashModeRGB8, 4, reverseVideoA, paperColorA, !fullScreenA)
91{
92 GString *initialZoom;
93
94 shell = shellA;
95 parentWidget = parentWidgetA;
96 display = XtDisplay(parentWidget);
97 screenNum = XScreenNumberOfScreen(XtScreen(parentWidget));
98 targetsAtom = XInternAtom(display, "TARGETS", False);
99
100 paperPixel = paperPixelA;
101 mattePixel = mattePixelA;
102 fullScreen = fullScreenA;
103
104 setupX(installCmap, rgbCubeSizeA);
105
106 scrolledWin = NULL;
107 hScrollBar = NULL;
108 vScrollBar = NULL;
109 drawAreaFrame = NULL;
110 drawArea = NULL;
111
112 // get the initial zoom value
113 if (fullScreen) {
114 zoom = zoomPage;
115 } else {
116 initialZoom = globalParams->getInitialZoom();
117 if (!initialZoom->cmp("page")) {
118 zoom = zoomPage;
119 } else if (!initialZoom->cmp("width")) {
120 zoom = zoomWidth;
121 } else {
122 zoom = atoi(initialZoom->getCString());
123 if (zoom <= 0) {
124 zoom = defZoom;
125 }
126 }
127 delete initialZoom;
128 }
129
130 linkAction = NULL;
131
132 panning = gFalse;
133
134 updateCbk = NULL;
135 actionCbk = NULL;
136 keyPressCbk = NULL;
137 mouseCbk = NULL;
138
139 // optional features default to on
140 hyperlinksEnabled = gTrue;
141 selectEnabled = gTrue;
142
143 // do X-specific initialization and create the widgets
144 initWindow();
145 initPasswordDialog();
146}
147
148XPDFCore::~XPDFCore() {
149 if (currentSelectionOwner == this && currentSelection) {
150 delete currentSelection;
151 currentSelection = NULL;
152 currentSelectionOwner = NULL;
153 }
154 if (drawAreaGC) {
155 XFreeGC(display, drawAreaGC);
156 }
157 if (scrolledWin) {
158 XtDestroyWidget(scrolledWin);
159 }
160 if (busyCursor) {
161 XFreeCursor(display, busyCursor);
162 }
163 if (linkCursor) {
164 XFreeCursor(display, linkCursor);
165 }
166 if (selectCursor) {
167 XFreeCursor(display, selectCursor);
168 }
169}
170
171//------------------------------------------------------------------------
172// loadFile / displayPage / displayDest
173//------------------------------------------------------------------------
174
175int XPDFCore::loadFile(GString *fileName, GString *ownerPassword,
176 GString *userPassword) {
177 int err;
178
179 err = PDFCore::loadFile(fileName, ownerPassword, userPassword);
180 if (err == errNone) {
181 // save the modification time
182 modTime = getModTime(doc->getFileName()->getCString());
183
184 // update the parent window
185 if (updateCbk) {
186 (*updateCbk)(updateCbkData, doc->getFileName(), -1,
187 doc->getNumPages(), NULL);
188 }
189 }
190 return err;
191}
192
193int XPDFCore::loadFile(BaseStream *stream, GString *ownerPassword,
194 GString *userPassword) {
195 int err;
196
197 err = PDFCore::loadFile(stream, ownerPassword, userPassword);
198 if (err == errNone) {
199 // no file
200 modTime = 0;
201
202 // update the parent window
203 if (updateCbk) {
204 (*updateCbk)(updateCbkData, doc->getFileName(), -1,
205 doc->getNumPages(), NULL);
206 }
207 }
208 return err;
209}
210
211void XPDFCore::loadDoc(PDFDoc *docA) {
212 PDFCore::loadDoc(docA);
213
214 // save the modification time
215 if (doc->getFileName()) {
216 modTime = getModTime(doc->getFileName()->getCString());
217 }
218
219 // update the parent window
220 if (updateCbk) {
221 (*updateCbk)(updateCbkData, doc->getFileName(), -1,
222 doc->getNumPages(), NULL);
223 }
224}
225
226void XPDFCore::resizeToPage(int pg) {
227 Dimension width, height;
228 double width1, height1;
229 Dimension topW, topH, topBorder, daW, daH;
230 Dimension displayW, displayH;
231
232 displayW = DisplayWidth(display, screenNum);
233 displayH = DisplayHeight(display, screenNum);
234 if (fullScreen) {
235 width = displayW;
236 height = displayH;
237 } else {
238 if (!doc || pg <= 0 || pg > doc->getNumPages()) {
239 width1 = 612;
240 height1 = 792;
241 } else if (doc->getPageRotate(pg) == 90 ||
242 doc->getPageRotate(pg) == 270) {
243 width1 = doc->getPageCropHeight(pg);
244 height1 = doc->getPageCropWidth(pg);
245 } else {
246 width1 = doc->getPageCropWidth(pg);
247 height1 = doc->getPageCropHeight(pg);
248 }
249 if (zoom == zoomPage || zoom == zoomWidth) {
250 width = (Dimension)(width1 * 0.01 * defZoom + 0.5);
251 height = (Dimension)(height1 * 0.01 * defZoom + 0.5);
252 } else {
253 width = (Dimension)(width1 * 0.01 * zoom + 0.5);
254 height = (Dimension)(height1 * 0.01 * zoom + 0.5);
255 }
256 if (continuousMode) {
257 height += continuousModePageSpacing;
258 }
259 if (width > displayW - 100) {
260 width = displayW - 100;
261 }
262 if (height > displayH - 100) {
263 height = displayH - 100;
264 }
265 }
266
267 if (XtIsRealized(shell)) {
268 XtVaGetValues(shell, XmNwidth, &topW, XmNheight, &topH,
269 XmNborderWidth, &topBorder, NULL);
270 XtVaGetValues(drawArea, XmNwidth, &daW, XmNheight, &daH, NULL);
271 XtVaSetValues(shell, XmNwidth, width + (topW - daW),
272 XmNheight, height + (topH - daH), NULL);
273 } else {
274 XtVaSetValues(drawArea, XmNwidth, width, XmNheight, height, NULL);
275 }
276}
277
278void XPDFCore::update(int topPageA, int scrollXA, int scrollYA,
279 double zoomA, int rotateA,
280 GBool force, GBool addToHist) {
281 int oldPage;
282
283 oldPage = topPage;
284 PDFCore::update(topPageA, scrollXA, scrollYA, zoomA, rotateA,
285 force, addToHist);
286 linkAction = NULL;
287 if (doc && topPage != oldPage) {
288 if (updateCbk) {
289 (*updateCbk)(updateCbkData, NULL, topPage, -1, "");
290 }
291 }
292}
293
294GBool XPDFCore::checkForNewFile() {
295 time_t newModTime;
296
297 if (doc->getFileName()) {
298 newModTime = getModTime(doc->getFileName()->getCString());
299 if (newModTime != modTime) {
300 modTime = newModTime;
301 return gTrue;
302 }
303 }
304 return gFalse;
305}
306
307//------------------------------------------------------------------------
308// page/position changes
309//------------------------------------------------------------------------
310
311GBool XPDFCore::gotoNextPage(int inc, GBool top) {
312 if (!PDFCore::gotoNextPage(inc, top)) {
313 XBell(display, 0);
314 return gFalse;
315 }
316 return gTrue;
317}
318
319GBool XPDFCore::gotoPrevPage(int dec, GBool top, GBool bottom) {
320 if (!PDFCore::gotoPrevPage(dec, top, bottom)) {
321 XBell(display, 0);
322 return gFalse;
323 }
324 return gTrue;
325}
326
327GBool XPDFCore::goForward() {
328 if (!PDFCore::goForward()) {
329 XBell(display, 0);
330 return gFalse;
331 }
332 return gTrue;
333}
334
335GBool XPDFCore::goBackward() {
336 if (!PDFCore::goBackward()) {
337 XBell(display, 0);
338 return gFalse;
339 }
340 return gTrue;
341}
342
343void XPDFCore::startPan(int wx, int wy) {
344 panning = gTrue;
345 panMX = wx;
346 panMY = wy;
347}
348
349void XPDFCore::endPan(int wx, int wy) {
350 panning = gFalse;
351}
352
353//------------------------------------------------------------------------
354// selection
355//------------------------------------------------------------------------
356
357void XPDFCore::startSelection(int wx, int wy) {
358 int pg, x, y;
359
360 takeFocus();
361 if (doc && doc->getNumPages() > 0) {
362 if (selectEnabled) {
363 if (cvtWindowToDev(wx, wy, &pg, &x, &y)) {
364 setSelection(pg, x, y, x, y);
365 setCursor(selectCursor);
366 dragging = gTrue;
367 }
368 }
369 }
370}
371
372void XPDFCore::endSelection(int wx, int wy) {
373 int pg, x, y;
374 GBool ok;
375
376 if (doc && doc->getNumPages() > 0) {
377 ok = cvtWindowToDev(wx, wy, &pg, &x, &y);
378 if (dragging) {
379 dragging = gFalse;
380 setCursor(None);
381 if (ok) {
382 moveSelection(pg, x, y);
383 }
384#ifndef NO_TEXT_SELECT
385 if (selectULX != selectLRX &&
386 selectULY != selectLRY) {
387 if (doc->okToCopy()) {
388 copySelection();
389 } else {
390 error(-1, "Copying of text from this document is not allowed.");
391 }
392 }
393#endif
394 }
395 }
396}
397
398// X's copy-and-paste mechanism is brain damaged. Xt doesn't help
399// any, but doesn't make it too much worse, either. Motif, on the
400// other hand, adds significant complexity to the mess. So here we
401// blow off the Motif junk and stick to plain old Xt. The next two
402// functions (copySelection and convertSelectionCbk) implement the
403// magic needed to deal with Xt's mechanism. Note that this requires
404// global variables (currentSelection and currentSelectionOwner).
405
406void XPDFCore::copySelection() {
407 int pg;
408 double ulx, uly, lrx, lry;
409
410 if (!doc->okToCopy()) {
411 return;
412 }
413 if (getSelection(&pg, &ulx, &uly, &lrx, &lry)) {
414 //~ for multithreading: need a mutex here
415 if (currentSelection) {
416 delete currentSelection;
417 }
418 currentSelection = extractText(pg, ulx, uly, lrx, lry);
419 currentSelectionOwner = this;
420 XtOwnSelection(drawArea, XA_PRIMARY, XtLastTimestampProcessed(display),
421 &convertSelectionCbk, NULL, NULL);
422 }
423}
424
425Boolean XPDFCore::convertSelectionCbk(Widget widget, Atom *selection,
426 Atom *target, Atom *type,
427 XtPointer *value, unsigned long *length,
428 int *format) {
429 Atom *array;
430
431 // send back a list of supported conversion targets
432 if (*target == targetsAtom) {
433 if (!(array = (Atom *)XtMalloc(sizeof(Atom)))) {
434 return False;
435 }
436 array[0] = XA_STRING;
437 *value = (XtPointer)array;
438 *type = XA_ATOM;
439 *format = 32;
440 *length = 1;
441 return True;
442
443 // send the selected text
444 } else if (*target == XA_STRING) {
445 //~ for multithreading: need a mutex here
446 *value = XtNewString(currentSelection->getCString());
447 *length = currentSelection->getLength();
448 *type = XA_STRING;
449 *format = 8; // 8-bit elements
450 return True;
451 }
452
453 return False;
454}
455
456//------------------------------------------------------------------------
457// hyperlinks
458//------------------------------------------------------------------------
459
460void XPDFCore::doAction(LinkAction *action) {
461 LinkActionKind kind;
462 LinkDest *dest;
463 GString *namedDest;
464 char *s;
465 GString *fileName, *fileName2;
466 GString *cmd;
467 GString *actionName;
468 Object movieAnnot, obj1, obj2;
469 GString *msg;
470 int i;
471
472 switch (kind = action->getKind()) {
473
474 // GoTo / GoToR action
475 case actionGoTo:
476 case actionGoToR:
477 if (kind == actionGoTo) {
478 dest = NULL;
479 namedDest = NULL;
480 if ((dest = ((LinkGoTo *)action)->getDest())) {
481 dest = dest->copy();
482 } else if ((namedDest = ((LinkGoTo *)action)->getNamedDest())) {
483 namedDest = namedDest->copy();
484 }
485 } else {
486 dest = NULL;
487 namedDest = NULL;
488 if ((dest = ((LinkGoToR *)action)->getDest())) {
489 dest = dest->copy();
490 } else if ((namedDest = ((LinkGoToR *)action)->getNamedDest())) {
491 namedDest = namedDest->copy();
492 }
493 s = ((LinkGoToR *)action)->getFileName()->getCString();
494 //~ translate path name for VMS (deal with '/')
495 if (isAbsolutePath(s)) {
496 fileName = new GString(s);
497 } else {
498 fileName = appendToPath(grabPath(doc->getFileName()->getCString()), s);
499 }
500 if (loadFile(fileName) != errNone) {
501 if (dest) {
502 delete dest;
503 }
504 if (namedDest) {
505 delete namedDest;
506 }
507 delete fileName;
508 return;
509 }
510 delete fileName;
511 }
512 if (namedDest) {
513 dest = doc->findDest(namedDest);
514 delete namedDest;
515 }
516 if (dest) {
517 displayDest(dest, zoom, rotate, gTrue);
518 delete dest;
519 } else {
520 if (kind == actionGoToR) {
521 displayPage(1, zoom, 0, gFalse, gTrue);
522 }
523 }
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: