CWS-TOOLING: integrate CWS mba30fixes02
This commit is contained in:
parent
ad3329977d
commit
c15bd97d0c
15 changed files with 41303 additions and 0 deletions
63
sdext/source/pdfimport/xpdftest/makefile.mk
Normal file
63
sdext/source/pdfimport/xpdftest/makefile.mk
Normal file
|
@ -0,0 +1,63 @@
|
|||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# Copyright 2008 by Sun Microsystems, Inc.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
#
|
||||
# $RCSfile: makefile.mk,v $
|
||||
#
|
||||
# $Revision: 1.1.2.2 $
|
||||
#
|
||||
# This file is part of OpenOffice.org.
|
||||
#
|
||||
# OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# only, as published by the Free Software Foundation.
|
||||
#
|
||||
# OpenOffice.org is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License version 3 for more details
|
||||
# (a copy is included in the LICENSE file that accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# version 3 along with OpenOffice.org. If not, see
|
||||
# <http://www.openoffice.org/license.html>
|
||||
# for a copy of the LGPLv3 License.
|
||||
#
|
||||
#*************************************************************************
|
||||
|
||||
PRJ=..$/..$/..
|
||||
PRJNAME=sdext
|
||||
TARGET=xpdftest
|
||||
TARGETTYPE=CUI
|
||||
ENABLE_EXCEPTIONS=TRUE
|
||||
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
.INCLUDE: settings.mk
|
||||
|
||||
.IF "$(ENABLE_PDFIMPORT)" == "NO"
|
||||
@all:
|
||||
@echo "PDF Import extension disabled."
|
||||
.ENDIF
|
||||
|
||||
# --- Targets ------------------------------------------------------
|
||||
|
||||
.INCLUDE : target.mk
|
||||
|
||||
#ALLTAR : $(MISC)$/test_0_succeeded $(MISC)$/test_1_succeeded
|
||||
|
||||
$(MISC)$/test_0_succeeded: $(BIN)$/xpdfimport$(EXECPOST) binary_0_out.def text_0_out.def testinput.pdf
|
||||
$(BIN)$/xpdfimport -f $(MISC)$/binary_0_out testinput.pdf > $(MISC)$/text_0_out
|
||||
diff --strip-trailing-cr $(MISC)$/binary_0_out binary_0_out.def
|
||||
diff --strip-trailing-cr $(MISC)$/text_0_out text_0_out.def
|
||||
$(TOUCH) $@
|
||||
|
||||
$(MISC)$/test_1_succeeded: $(BIN)$/xpdfimport$(EXECPOST) binary_1_out.def text_1_out.def book.pdf
|
||||
$(BIN)$/xpdfimport -f $(MISC)$/binary_1_out book.pdf > $(MISC)$/text_1_out
|
||||
diff --strip-trailing-cr $(MISC)$/binary_1_out binary_1_out.def
|
||||
diff --strip-trailing-cr $(MISC)$/text_1_out text_1_out.def
|
||||
$(TOUCH) $@
|
202
sdext/source/pdfimport/xpdftest/text_0_out.def
Normal file
202
sdext/source/pdfimport/xpdftest/text_0_out.def
Normal file
|
@ -0,0 +1,202 @@
|
|||
setPageNum 1
|
||||
startPage 79400.000000 59500.000000
|
||||
updateCtm 100.000000 0.000000 0.000000 -100.000000 0.000000 59500.000000
|
||||
updateLineDash
|
||||
updateFlatness 1
|
||||
updateLineJoin 0
|
||||
updateLineCap 0
|
||||
updateMiterLimit 10.000000
|
||||
updateLineWidth 1.000000
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateStrokeColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateStrokeColor 0.000000 0.000000 0.000000 1.000000
|
||||
clipPath subpath 1 0.000000 0.000000 0 794.000000 0.000000 0 794.000000 595.000000 0 0.000000 595.000000 0 0.000000 0.000000 0
|
||||
saveState
|
||||
updateLineWidth 0.100000
|
||||
saveState
|
||||
eoClipPath subpath 1 0.000000 -0.300000 0 793.800000 -0.300000 0 793.800000 595.000000 0 0.000000 595.000000 0 0.000000 -0.300000 0
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 16 1 0 0 0 1400.000000 10932 BAAAAA+Thorndale
|
||||
drawChar 39.700000 52.674000 43.200000 38.674000 1.000000 0.000000 0.000000 1.000000
|
||||
endTextObject
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 16 1 0 0 0 1400.000000 0 BAAAAA+Thorndale
|
||||
drawChar 395.400000 52.674000 398.900000 38.674000 1.000000 0.000000 0.000000 1.000000
|
||||
endTextObject
|
||||
restoreState
|
||||
updateStrokeColor 0.000000 0.000000 0.000000 1.000000
|
||||
saveState
|
||||
updateLineWidth 0.000000
|
||||
updateLineCap 0
|
||||
updateLineJoin 1
|
||||
updateLineDash 0.000000 4 14.376400 14.376400 14.376400 14.376400
|
||||
strokePath subpath 0 498.900000 538.300000 0 144.600000 297.400000 0
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 11 1 0 0 0 1800.000000 20752 CAAAAA+Albany
|
||||
drawChar 35.400000 466.790000 46.380000 448.790000 1.000000 0.000000 0.000000 1.000000 T
|
||||
drawChar 46.596000 466.790000 56.604000 448.790000 1.000000 0.000000 0.000000 1.000000 h
|
||||
drawChar 56.496000 466.790000 60.492000 448.790000 1.000000 0.000000 0.000000 1.000000 i
|
||||
drawChar 60.492000 466.790000 69.492000 448.790000 1.000000 0.000000 0.000000 1.000000 s
|
||||
drawChar 69.492000 466.790000 74.478000 448.790000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 74.496000 466.790000 78.492000 448.790000 1.000000 0.000000 0.000000 1.000000 i
|
||||
drawChar 78.492000 466.790000 87.492000 448.790000 1.000000 0.000000 0.000000 1.000000 s
|
||||
drawChar 87.492000 466.790000 92.478000 448.790000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 92.496000 466.790000 102.504000 448.790000 1.000000 0.000000 0.000000 1.000000 a
|
||||
drawChar 102.504000 466.790000 107.490000 448.790000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 107.508000 466.790000 112.494000 448.790000 1.000000 0.000000 0.000000 1.000000 t
|
||||
drawChar 112.602000 466.790000 122.610000 448.790000 1.000000 0.000000 0.000000 1.000000 e
|
||||
drawChar 122.502000 466.790000 131.502000 448.790000 1.000000 0.000000 0.000000 1.000000 s
|
||||
drawChar 131.502000 466.790000 136.488000 448.790000 1.000000 0.000000 0.000000 1.000000 t
|
||||
drawChar 136.596000 466.790000 141.582000 448.790000 1.000000 0.000000 0.000000 1.000000 t
|
||||
drawChar 141.600000 466.790000 151.608000 448.790000 1.000000 0.000000 0.000000 1.000000 e
|
||||
drawChar 151.608000 466.790000 160.608000 448.790000 1.000000 0.000000 0.000000 1.000000 x
|
||||
drawChar 160.410000 466.790000 165.396000 448.790000 1.000000 0.000000 0.000000 1.000000 t
|
||||
endTextObject
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 11 1 0 0 0 1800.000000 0 CAAAAA+Albany
|
||||
drawChar 35.400000 446.590000 48.396000 428.590000 1.000000 0.000000 0.000000 1.000000 N
|
||||
drawChar 48.396000 446.590000 58.404000 428.590000 1.000000 0.000000 0.000000 1.000000 e
|
||||
drawChar 58.296000 446.590000 71.292000 428.590000 1.000000 0.000000 0.000000 1.000000 w
|
||||
drawChar 70.896000 446.590000 75.882000 428.590000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 75.990000 446.590000 85.998000 428.590000 1.000000 0.000000 0.000000 1.000000 p
|
||||
drawChar 85.890000 446.590000 95.898000 428.590000 1.000000 0.000000 0.000000 1.000000 a
|
||||
drawChar 95.898000 446.590000 101.892000 428.590000 1.000000 0.000000 0.000000 1.000000 r
|
||||
drawChar 101.892000 446.590000 111.900000 428.590000 1.000000 0.000000 0.000000 1.000000 a
|
||||
drawChar 111.900000 446.590000 121.908000 428.590000 1.000000 0.000000 0.000000 1.000000 g
|
||||
drawChar 121.800000 446.590000 127.794000 428.590000 1.000000 0.000000 0.000000 1.000000 r
|
||||
drawChar 127.794000 446.590000 137.802000 428.590000 1.000000 0.000000 0.000000 1.000000 a
|
||||
drawChar 137.802000 446.590000 147.810000 428.590000 1.000000 0.000000 0.000000 1.000000 p
|
||||
drawChar 147.702000 446.590000 157.710000 428.590000 1.000000 0.000000 0.000000 1.000000 h
|
||||
drawChar 157.710000 446.590000 162.696000 428.590000 1.000000 0.000000 0.000000 1.000000 ,
|
||||
endTextObject
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 11 1 0 0 0 1800.000000 0 CAAAAA+Albany
|
||||
drawChar 35.400000 426.390000 45.408000 408.390000 1.000000 0.000000 0.000000 1.000000 n
|
||||
drawChar 45.408000 426.390000 55.416000 408.390000 1.000000 0.000000 0.000000 1.000000 e
|
||||
drawChar 55.308000 426.390000 68.304000 408.390000 1.000000 0.000000 0.000000 1.000000 w
|
||||
drawChar 67.908000 426.390000 72.894000 408.390000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 73.002000 426.390000 76.998000 408.390000 1.000000 0.000000 0.000000 1.000000 l
|
||||
drawChar 76.908000 426.390000 80.904000 408.390000 1.000000 0.000000 0.000000 1.000000 i
|
||||
drawChar 80.904000 426.390000 90.912000 408.390000 1.000000 0.000000 0.000000 1.000000 n
|
||||
drawChar 90.912000 426.390000 100.920000 408.390000 1.000000 0.000000 0.000000 1.000000 e
|
||||
endTextObject
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.799988 1.000000
|
||||
updateFont 11 1 0 0 0 1800.000000 0 CAAAAA+Albany
|
||||
drawChar 35.400000 406.190000 48.396000 388.190000 1.000000 0.000000 0.000000 1.000000 H
|
||||
drawChar 48.396000 406.190000 57.396000 388.190000 1.000000 0.000000 0.000000 1.000000 y
|
||||
drawChar 57.090000 406.190000 67.098000 388.190000 1.000000 0.000000 0.000000 1.000000 p
|
||||
drawChar 67.098000 406.190000 77.106000 388.190000 1.000000 0.000000 0.000000 1.000000 e
|
||||
drawChar 76.998000 406.190000 82.992000 388.190000 1.000000 0.000000 0.000000 1.000000 r
|
||||
drawChar 83.100000 406.190000 87.096000 388.190000 1.000000 0.000000 0.000000 1.000000 l
|
||||
drawChar 87.006000 406.190000 91.002000 388.190000 1.000000 0.000000 0.000000 1.000000 i
|
||||
drawChar 91.002000 406.190000 101.010000 388.190000 1.000000 0.000000 0.000000 1.000000 n
|
||||
drawChar 100.902000 406.190000 109.902000 388.190000 1.000000 0.000000 0.000000 1.000000 k
|
||||
drawChar 109.902000 406.190000 114.888000 388.190000 1.000000 0.000000 0.000000 1.000000 ,
|
||||
drawChar 114.996000 406.190000 119.982000 388.190000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 120.000000 406.190000 124.986000 388.190000 1.000000 0.000000 0.000000 1.000000 t
|
||||
drawChar 125.004000 406.190000 135.012000 388.190000 1.000000 0.000000 0.000000 1.000000 h
|
||||
drawChar 135.012000 406.190000 139.008000 388.190000 1.000000 0.000000 0.000000 1.000000 i
|
||||
drawChar 139.008000 406.190000 148.008000 388.190000 1.000000 0.000000 0.000000 1.000000 s
|
||||
drawChar 148.008000 406.190000 152.994000 388.190000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 153.012000 406.190000 157.008000 388.190000 1.000000 0.000000 0.000000 1.000000 i
|
||||
drawChar 157.008000 406.190000 166.008000 388.190000 1.000000 0.000000 0.000000 1.000000 s
|
||||
endTextObject
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 21 1 0 0 0 1440.000000 8140 DAAAAA+StarSymbol
|
||||
drawChar 405.400000 246.257600 416.171200 231.857600 1.000000 0.000000 0.000000 1.000000 ●
|
||||
endTextObject
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 11 1 0 0 0 3200.000000 0 CAAAAA+Albany
|
||||
drawChar 430.900000 254.760000 450.420000 222.760000 1.000000 0.000000 0.000000 1.000000 T
|
||||
drawChar 450.516000 254.760000 468.308000 222.760000 1.000000 0.000000 0.000000 1.000000 h
|
||||
drawChar 468.308000 254.760000 475.412000 222.760000 1.000000 0.000000 0.000000 1.000000 i
|
||||
drawChar 475.316000 254.760000 491.316000 222.760000 1.000000 0.000000 0.000000 1.000000 s
|
||||
drawChar 491.412000 254.760000 500.276000 222.760000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 500.308000 254.760000 507.412000 222.760000 1.000000 0.000000 0.000000 1.000000 i
|
||||
drawChar 507.412000 254.760000 523.412000 222.760000 1.000000 0.000000 0.000000 1.000000 s
|
||||
drawChar 523.412000 254.760000 532.276000 222.760000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 532.308000 254.760000 558.964000 222.760000 1.000000 0.000000 0.000000 1.000000 m
|
||||
drawChar 558.996000 254.760000 576.788000 222.760000 1.000000 0.000000 0.000000 1.000000 o
|
||||
drawChar 576.692000 254.760000 587.348000 222.760000 1.000000 0.000000 0.000000 1.000000 r
|
||||
drawChar 587.380000 254.760000 605.172000 222.760000 1.000000 0.000000 0.000000 1.000000 e
|
||||
drawChar 605.172000 254.760000 614.036000 222.760000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 613.972000 254.760000 622.836000 222.760000 1.000000 0.000000 0.000000 1.000000 t
|
||||
drawChar 622.868000 254.760000 640.660000 222.760000 1.000000 0.000000 0.000000 1.000000 e
|
||||
drawChar 640.660000 254.760000 656.660000 222.760000 1.000000 0.000000 0.000000 1.000000 x
|
||||
drawChar 656.756000 254.760000 665.620000 222.760000 1.000000 0.000000 0.000000 1.000000 t
|
||||
endTextObject
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 11 1 0 0 0 3200.000000 0 CAAAAA+Albany
|
||||
drawChar 430.900000 218.860000 448.692000 186.860000 1.000000 0.000000 0.000000 1.000000 o
|
||||
drawChar 448.692000 218.860000 466.484000 186.860000 1.000000 0.000000 0.000000 1.000000 u
|
||||
drawChar 466.388000 218.860000 475.252000 186.860000 1.000000 0.000000 0.000000 1.000000 t
|
||||
drawChar 475.284000 218.860000 482.388000 186.860000 1.000000 0.000000 0.000000 1.000000 l
|
||||
drawChar 482.388000 218.860000 489.492000 186.860000 1.000000 0.000000 0.000000 1.000000 i
|
||||
drawChar 489.492000 218.860000 507.284000 186.860000 1.000000 0.000000 0.000000 1.000000 n
|
||||
drawChar 507.188000 218.860000 524.980000 186.860000 1.000000 0.000000 0.000000 1.000000 e
|
||||
drawChar 524.980000 218.860000 533.844000 186.860000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 533.876000 218.860000 560.532000 186.860000 1.000000 0.000000 0.000000 1.000000 m
|
||||
drawChar 560.468000 218.860000 578.260000 186.860000 1.000000 0.000000 0.000000 1.000000 o
|
||||
drawChar 578.260000 218.860000 596.052000 186.860000 1.000000 0.000000 0.000000 1.000000 d
|
||||
drawChar 595.956000 218.860000 613.748000 186.860000 1.000000 0.000000 0.000000 1.000000 e
|
||||
endTextObject
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 21 1 0 0 0 1440.000000 0 DAAAAA+StarSymbol
|
||||
drawChar 405.400000 160.357600 416.171200 145.957600 1.000000 0.000000 0.000000 1.000000 ●
|
||||
endTextObject
|
||||
restoreState
|
||||
saveState
|
||||
updateFillColor 0.000000 0.000000 0.000000 1.000000
|
||||
updateFont 11 1 0 0 0 3200.000000 0 CAAAAA+Albany
|
||||
drawChar 430.900000 168.760000 454.004000 136.760000 1.000000 0.000000 0.000000 1.000000 N
|
||||
drawChar 454.100000 168.760000 471.892000 136.760000 1.000000 0.000000 0.000000 1.000000 e
|
||||
drawChar 471.892000 168.760000 494.996000 136.760000 1.000000 0.000000 0.000000 1.000000 w
|
||||
drawChar 494.996000 168.760000 503.860000 136.760000 1.000000 0.000000 0.000000 1.000000
|
||||
drawChar 503.892000 168.760000 521.684000 136.760000 1.000000 0.000000 0.000000 1.000000 p
|
||||
drawChar 521.588000 168.760000 539.380000 136.760000 1.000000 0.000000 0.000000 1.000000 a
|
||||
drawChar 539.380000 168.760000 550.036000 136.760000 1.000000 0.000000 0.000000 1.000000 r
|
||||
drawChar 550.068000 168.760000 567.860000 136.760000 1.000000 0.000000 0.000000 1.000000 a
|
||||
drawChar 567.764000 168.760000 585.556000 136.760000 1.000000 0.000000 0.000000 1.000000 g
|
||||
drawChar 585.556000 168.760000 596.212000 136.760000 1.000000 0.000000 0.000000 1.000000 r
|
||||
drawChar 596.244000 168.760000 614.036000 136.760000 1.000000 0.000000 0.000000 1.000000 a
|
||||
drawChar 613.940000 168.760000 631.732000 136.760000 1.000000 0.000000 0.000000 1.000000 p
|
||||
drawChar 631.732000 168.760000 649.524000 136.760000 1.000000 0.000000 0.000000 1.000000 h
|
||||
endTextObject
|
||||
restoreState
|
||||
updateFillColor 1.000000 0.000000 0.000000 1.000000
|
||||
eoFillPath subpath 1 120.500000 98.900000 0 77.400000 98.900000 1 42.500000 133.800000 1 42.500000 176.900000 0 42.500000 219.900000 1 77.400000 254.800000 1 120.500000 254.800000 0 163.500000 254.800000 1 198.400000 219.900000 1 198.400000 176.900000 0 198.400000 133.800000 1 163.500000 98.900000 1 120.500000 98.900000 0
|
||||
saveState
|
||||
updateCtm 22680.000000 0.000000 0.000000 -14740.000000 49610.000000 27490.000000
|
||||
drawImage 800 600 0 JPEG 44129
|
||||
restoreState
|
||||
updateStrokeColor 0.000000 1.000000 0.000000 1.000000
|
||||
saveState
|
||||
updateLineWidth 28.300000
|
||||
updateLineCap 0
|
||||
updateLineJoin 1
|
||||
strokePath subpath 0 535.700000 518.500000 0 181.400000 277.500000 0
|
||||
restoreState
|
||||
restoreState
|
||||
restoreState
|
||||
endPage
|
||||
drawLink 34.700000 386.000000 166.700000 406.200000 http://download.openoffice.org/
|
39667
sdext/source/pdfimport/xpdftest/text_1_out.def
Normal file
39667
sdext/source/pdfimport/xpdftest/text_1_out.def
Normal file
File diff suppressed because it is too large
Load diff
81
sdext/source/pdfimport/xpdfwrapper/makefile.mk
Normal file
81
sdext/source/pdfimport/xpdfwrapper/makefile.mk
Normal file
|
@ -0,0 +1,81 @@
|
|||
#*************************************************************************
|
||||
#
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# Copyright 2008 by Sun Microsystems, Inc.
|
||||
#
|
||||
# OpenOffice.org - a multi-platform office productivity suite
|
||||
#
|
||||
# $RCSfile: makefile.mk,v $
|
||||
#
|
||||
# $Revision: 1.1.2.2 $
|
||||
#
|
||||
# This file is part of OpenOffice.org.
|
||||
#
|
||||
# OpenOffice.org is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# only, as published by the Free Software Foundation.
|
||||
#
|
||||
# OpenOffice.org is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License version 3 for more details
|
||||
# (a copy is included in the LICENSE file that accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# version 3 along with OpenOffice.org. If not, see
|
||||
# <http://www.openoffice.org/license.html>
|
||||
# for a copy of the LGPLv3 License.
|
||||
#
|
||||
#*************************************************************************
|
||||
|
||||
PRJ=..$/..$/..
|
||||
|
||||
PRJNAME=sdext
|
||||
TARGET=xpdfimport
|
||||
TARGETTYPE=CUI
|
||||
ENABLE_EXCEPTIONS=TRUE
|
||||
EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
|
||||
|
||||
# --- Settings -----------------------------------------------------
|
||||
|
||||
.INCLUDE: settings.mk
|
||||
|
||||
.IF "$(ENABLE_PDFIMPORT)" == "NO"
|
||||
@all:
|
||||
@echo "PDF Import extension disabled."
|
||||
.ENDIF
|
||||
|
||||
.IF "$(SYSTEM_POPPLER)" == "YES"
|
||||
CFLAGS += $(POPPLER_CFLAGS) -DSYSTEM_POPPLER
|
||||
.ELSE
|
||||
CFLAGS += -I$(SOLARINCDIR)$/xpdf
|
||||
.ENDIF
|
||||
|
||||
# --- Files --------------------------------------------------------
|
||||
UWINAPILIB:=
|
||||
APP1TARGET=$(TARGET)
|
||||
APP1LIBSALCPPRT=
|
||||
APP1OBJS= \
|
||||
$(OBJ)$/wrapper_gpl.obj $(OBJ)/pdfioutdev_gpl.obj
|
||||
|
||||
|
||||
.IF "$(SYSTEM_POPPLER)" == "YES"
|
||||
APP1STDLIBS+=$(POPPLER_LIBS)
|
||||
.ELSE
|
||||
.IF "$(GUI)" == "WNT"
|
||||
.IF "$(COM)"=="GCC"
|
||||
APP1STDLIBS+=-lxpdf -lfofi -lGoo -lgdi32 -ladvapi32
|
||||
.ELSE
|
||||
APP1STDLIBS+=xpdf.lib fofi.lib Goo.lib gdi32.lib advapi32.lib
|
||||
.ENDIF
|
||||
.ELSE
|
||||
.IF "$(OS)" == "MACOSX" && "$(GUIBASE)"=="unx"
|
||||
APP1STDLIBS+=-lobjc
|
||||
.ENDIF
|
||||
APP1STDLIBS+=-lxpdf -lfofi -lGoo
|
||||
.ENDIF
|
||||
.ENDIF
|
||||
# --- Targets ------------------------------------------------------
|
||||
|
||||
.INCLUDE : target.mk
|
796
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
Normal file
796
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
Normal file
|
@ -0,0 +1,796 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: pdfioutdev_gpl.cxx,v $
|
||||
*
|
||||
* $Revision: 1.1.2.1 $
|
||||
*
|
||||
* last change: $Author: cmc $ $Date: 2008/08/25 16:17:55 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU General Public License Version 2.
|
||||
*
|
||||
*
|
||||
* GNU General Public License, version 2
|
||||
* =============================================
|
||||
* Copyright 2005 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#include "pdfioutdev_gpl.hxx"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <vector>
|
||||
|
||||
#if defined __SUNPRO_CC
|
||||
#pragma disable_warn
|
||||
#elif defined _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
#endif
|
||||
|
||||
#include "UTF8.h"
|
||||
|
||||
#if defined __SUNPRO_CC
|
||||
#pragma enable_warn
|
||||
#elif defined _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#ifdef WNT
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
/* SYNC STREAMS
|
||||
============
|
||||
|
||||
We stream human-readble tokens to stdout, and binary data (fonts,
|
||||
bitmaps) to g_binary_out. Another process reads from those pipes, and
|
||||
there lies the rub: things can deadlock, if the two involved
|
||||
processes access the pipes in different order. At any point in
|
||||
time, both processes must access the same pipe. To ensure this,
|
||||
data must be flushed to the OS before writing to a different pipe,
|
||||
otherwise not-yet-written data will leave the reading process
|
||||
waiting on the wrong pipe.
|
||||
*/
|
||||
|
||||
namespace pdfi
|
||||
{
|
||||
|
||||
/// cut off very small numbers & clamp value to zero
|
||||
inline double normalize( double val )
|
||||
{
|
||||
return fabs(val) < 0.0000001 ? 0.0 : val;
|
||||
}
|
||||
|
||||
const char* escapeLineFeed( const char* pStr )
|
||||
{
|
||||
// TODO(Q3): Escape linefeeds
|
||||
return pStr;
|
||||
}
|
||||
|
||||
/// for the temp char buffer the header gets snprintfed in
|
||||
#define WRITE_BUFFER_SIZE 1024
|
||||
|
||||
/// for the initial std::vector capacity when copying stream from xpdf
|
||||
#define WRITE_BUFFER_INITIAL_CAPACITY (1024*100)
|
||||
|
||||
typedef std::vector<char> OutputBuffer;
|
||||
|
||||
void initBuf(OutputBuffer& io_rBuffer)
|
||||
{
|
||||
io_rBuffer.reserve(WRITE_BUFFER_INITIAL_CAPACITY);
|
||||
}
|
||||
|
||||
void writeBinaryBuffer( const OutputBuffer& rBuffer )
|
||||
{
|
||||
// ---sync point--- see SYNC STREAMS above
|
||||
fflush(stdout);
|
||||
|
||||
// put buffer to stderr
|
||||
if( !rBuffer.empty() )
|
||||
if( fwrite(&rBuffer[0], sizeof(char),
|
||||
rBuffer.size(), g_binary_out) != (size_t)rBuffer.size() )
|
||||
exit(1); // error
|
||||
|
||||
// ---sync point--- see SYNC STREAMS above
|
||||
fflush(g_binary_out);
|
||||
}
|
||||
|
||||
void writeJpeg_( OutputBuffer& o_rOutputBuf, Stream* str, bool bWithLinefeed )
|
||||
{
|
||||
// dump JPEG file as-is
|
||||
str = ((DCTStream *)str)->getRawStream();
|
||||
str->reset();
|
||||
|
||||
int c;
|
||||
o_rOutputBuf.clear();
|
||||
while((c=str->getChar()) != EOF)
|
||||
o_rOutputBuf.push_back(static_cast<char>(c));
|
||||
|
||||
printf( " JPEG %d", o_rOutputBuf.size() );
|
||||
if( bWithLinefeed )
|
||||
printf("\n");
|
||||
|
||||
str->close();
|
||||
}
|
||||
|
||||
void writePbm_(OutputBuffer& o_rOutputBuf, Stream* str, int width, int height, bool bWithLinefeed)
|
||||
{
|
||||
// write as PBM (char by char, to avoid stdlib lineend messing)
|
||||
o_rOutputBuf.clear();
|
||||
o_rOutputBuf.resize(WRITE_BUFFER_SIZE);
|
||||
o_rOutputBuf[0] = 'P';
|
||||
o_rOutputBuf[1] = '4';
|
||||
o_rOutputBuf[2] = 0x0A;
|
||||
int nOutLen = snprintf(&o_rOutputBuf[3], WRITE_BUFFER_SIZE-10, "%d %d", width, height);
|
||||
if( nOutLen < 0 )
|
||||
nOutLen = WRITE_BUFFER_SIZE-10;
|
||||
o_rOutputBuf[3+nOutLen] =0x0A;
|
||||
o_rOutputBuf[3+nOutLen+1]=0;
|
||||
|
||||
const int header_size = 3+nOutLen+1;
|
||||
const int size = height * ((width + 7) / 8);
|
||||
|
||||
printf( " PBM %d", size + header_size );
|
||||
if( bWithLinefeed )
|
||||
printf("\n");
|
||||
|
||||
// trim buffer to exact header length
|
||||
o_rOutputBuf.resize(header_size);
|
||||
|
||||
// initialize stream
|
||||
str->reset();
|
||||
|
||||
// copy the raw stream
|
||||
for( int i=0; i<size; ++i)
|
||||
o_rOutputBuf.push_back(static_cast<char>(str->getChar()));
|
||||
|
||||
str->close();
|
||||
}
|
||||
|
||||
// stolen from ImageOutputDev.cc
|
||||
void writeMask_( OutputBuffer& o_rOutputBuf, Stream* str, int width, int height, bool bWithLinefeed )
|
||||
{
|
||||
if( str->getKind() == strDCT )
|
||||
writeJpeg_(o_rOutputBuf, str, bWithLinefeed);
|
||||
else
|
||||
writePbm_(o_rOutputBuf, str, width, height, bWithLinefeed);
|
||||
}
|
||||
|
||||
void writeImage_( OutputBuffer& o_rOutputBuf,
|
||||
Stream* str,
|
||||
int width,
|
||||
int height,
|
||||
GfxImageColorMap* colorMap,
|
||||
bool bWithLinefeed )
|
||||
{
|
||||
// dump JPEG file
|
||||
if( str->getKind() == strDCT &&
|
||||
(colorMap->getNumPixelComps() == 1 ||
|
||||
colorMap->getNumPixelComps() == 3) )
|
||||
{
|
||||
writeJpeg_(o_rOutputBuf, str, bWithLinefeed);
|
||||
}
|
||||
else if (colorMap->getNumPixelComps() == 1 &&
|
||||
colorMap->getBits() == 1)
|
||||
{
|
||||
writePbm_(o_rOutputBuf, str, width, height, bWithLinefeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
// write as PPM (char by char, to avoid stdlib lineend messing)
|
||||
o_rOutputBuf.clear();
|
||||
o_rOutputBuf.resize(WRITE_BUFFER_SIZE);
|
||||
o_rOutputBuf[0] = 'P';
|
||||
o_rOutputBuf[1] = '6';
|
||||
o_rOutputBuf[2] = '\n';
|
||||
int nOutLen = snprintf(&o_rOutputBuf[3], WRITE_BUFFER_SIZE-10, "%d %d", width, height);
|
||||
if( nOutLen < 0 )
|
||||
nOutLen = WRITE_BUFFER_SIZE-10;
|
||||
o_rOutputBuf[3+nOutLen] ='\n';
|
||||
o_rOutputBuf[3+nOutLen+1]='2';
|
||||
o_rOutputBuf[3+nOutLen+2]='5';
|
||||
o_rOutputBuf[3+nOutLen+3]='5';
|
||||
o_rOutputBuf[3+nOutLen+4]='\n';
|
||||
o_rOutputBuf[3+nOutLen+5]=0;
|
||||
|
||||
const int header_size = 3+nOutLen+5;
|
||||
const int size = width*height*3 + header_size;
|
||||
|
||||
printf( " PPM %d", size );
|
||||
if( bWithLinefeed )
|
||||
printf("\n");
|
||||
|
||||
// trim buffer to exact header size
|
||||
o_rOutputBuf.resize(header_size);
|
||||
|
||||
// initialize stream
|
||||
Guchar *p;
|
||||
GfxRGB rgb;
|
||||
ImageStream* imgStr =
|
||||
new ImageStream(str,
|
||||
width,
|
||||
colorMap->getNumPixelComps(),
|
||||
colorMap->getBits());
|
||||
imgStr->reset();
|
||||
|
||||
for( int y=0; y<height; ++y)
|
||||
{
|
||||
p = imgStr->getLine();
|
||||
for( int x=0; x<width; ++x)
|
||||
{
|
||||
colorMap->getRGB(p, &rgb);
|
||||
o_rOutputBuf.push_back(colToByte(rgb.r));
|
||||
o_rOutputBuf.push_back(colToByte(rgb.g));
|
||||
o_rOutputBuf.push_back(colToByte(rgb.b));
|
||||
|
||||
p +=colorMap->getNumPixelComps();
|
||||
}
|
||||
}
|
||||
|
||||
delete imgStr;
|
||||
}
|
||||
}
|
||||
|
||||
// forwarders
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
inline void writeImage( OutputBuffer& o_rOutputBuf,
|
||||
Stream* str,
|
||||
int width,
|
||||
int height,
|
||||
GfxImageColorMap* colorMap ) { writeImage_(o_rOutputBuf,str,width,height,colorMap,false); }
|
||||
inline void writeImageLF( OutputBuffer& o_rOutputBuf,
|
||||
Stream* str,
|
||||
int width,
|
||||
int height,
|
||||
GfxImageColorMap* colorMap ) { writeImage_(o_rOutputBuf,str,width,height,colorMap,true); }
|
||||
inline void writeMask( OutputBuffer& o_rOutputBuf,
|
||||
Stream* str,
|
||||
int width,
|
||||
int height ) { writeMask_(o_rOutputBuf,str,width,height,false); }
|
||||
inline void writeMaskLF( OutputBuffer& o_rOutputBuf,
|
||||
Stream* str,
|
||||
int width,
|
||||
int height ) { writeMask_(o_rOutputBuf,str,width,height,true); }
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
||||
int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, GfxState* state ) const
|
||||
{
|
||||
FontAttributes aNewFont;
|
||||
int nSize = 0;
|
||||
|
||||
GooString* pFamily = gfxFont->getName();
|
||||
if( ! pFamily )
|
||||
pFamily = gfxFont->getOrigName();
|
||||
if( pFamily )
|
||||
{
|
||||
aNewFont.familyName.clear();
|
||||
aNewFont.familyName.append( gfxFont->getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
aNewFont.familyName.clear();
|
||||
aNewFont.familyName.append( "Arial" );
|
||||
}
|
||||
|
||||
aNewFont.isBold = gfxFont->isBold();
|
||||
aNewFont.isItalic = gfxFont->isItalic();
|
||||
aNewFont.size = state->getTransformedFontSize();
|
||||
aNewFont.isUnderline = false;
|
||||
|
||||
if( gfxFont->getType() == fontTrueType || gfxFont->getType() == fontType1 )
|
||||
{
|
||||
// TODO(P3): Unfortunately, need to read stream twice, since
|
||||
// we must write byte count to stdout before
|
||||
char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize );
|
||||
if( pBuf )
|
||||
aNewFont.isEmbedded = true;
|
||||
}
|
||||
|
||||
m_aFontMap[ nNewId ] = aNewFont;
|
||||
return nSize;
|
||||
}
|
||||
|
||||
void PDFOutDev::writeFontFile( GfxFont* gfxFont ) const
|
||||
{
|
||||
if( gfxFont->getType() != fontTrueType && gfxFont->getType() != fontType1 )
|
||||
return;
|
||||
|
||||
int nSize = 0;
|
||||
char* pBuf = gfxFont->readEmbFontFile( m_pDoc->getXRef(), &nSize );
|
||||
if( !pBuf )
|
||||
return;
|
||||
|
||||
// ---sync point--- see SYNC STREAMS above
|
||||
fflush(stdout);
|
||||
|
||||
if( fwrite(pBuf, sizeof(char), nSize, g_binary_out) != (size_t)nSize )
|
||||
exit(1); // error
|
||||
|
||||
// ---sync point--- see SYNC STREAMS above
|
||||
fflush(g_binary_out);
|
||||
}
|
||||
|
||||
void PDFOutDev::printPath( GfxPath* pPath ) const
|
||||
{
|
||||
int nSubPaths = pPath ? pPath->getNumSubpaths() : 0;
|
||||
for( int i=0; i<nSubPaths; i++ )
|
||||
{
|
||||
GfxSubpath* pSub = pPath->getSubpath( i );
|
||||
const int nPoints = pSub->getNumPoints();
|
||||
|
||||
printf( " subpath %d", pSub->isClosed() );
|
||||
|
||||
for( int n=0; n<nPoints; ++n )
|
||||
{
|
||||
printf( " %f %f %d",
|
||||
normalize(pSub->getX(n)),
|
||||
normalize(pSub->getY(n)),
|
||||
pSub->getCurve(n) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PDFOutDev::PDFOutDev( PDFDoc* pDoc ) :
|
||||
m_pDoc( pDoc ),
|
||||
m_aFontMap(),
|
||||
m_pUtf8Map( new UnicodeMap("UTF-8", gTrue, &mapUTF8) )
|
||||
{
|
||||
}
|
||||
|
||||
void PDFOutDev::startPage(int /*pageNum*/, GfxState* state)
|
||||
{
|
||||
assert(state);
|
||||
printf("startPage %f %f\n",
|
||||
normalize(state->getPageWidth()),
|
||||
normalize(state->getPageHeight()));
|
||||
}
|
||||
|
||||
void PDFOutDev::endPage()
|
||||
{
|
||||
printf("endPage\n");
|
||||
}
|
||||
|
||||
void PDFOutDev::processLink(Link* link, Catalog*)
|
||||
{
|
||||
assert(link);
|
||||
|
||||
double x1,x2,y1,y2;
|
||||
link->getRect( &x1, &y1, &x2, &y2 );
|
||||
|
||||
LinkAction* pAction = link->getAction();
|
||||
if( pAction->getKind() == actionURI )
|
||||
{
|
||||
const char* pURI = static_cast<LinkURI*>(pAction)->getURI()->getCString();
|
||||
|
||||
printf( "drawLink %f %f %f %f %s\n",
|
||||
normalize(x1),
|
||||
normalize(y1),
|
||||
normalize(x2),
|
||||
normalize(y2),
|
||||
escapeLineFeed(pURI) );
|
||||
}
|
||||
}
|
||||
|
||||
void PDFOutDev::saveState(GfxState*)
|
||||
{
|
||||
printf( "saveState\n" );
|
||||
}
|
||||
|
||||
void PDFOutDev::restoreState(GfxState*)
|
||||
{
|
||||
printf( "restoreState\n" );
|
||||
}
|
||||
|
||||
void PDFOutDev::setDefaultCTM(double *pMat)
|
||||
{
|
||||
assert(pMat);
|
||||
|
||||
OutputDev::setDefaultCTM(pMat);
|
||||
|
||||
printf( "updateCtm %f %f %f %f %f %f\n",
|
||||
normalize(pMat[0]),
|
||||
normalize(pMat[2]),
|
||||
normalize(pMat[1]),
|
||||
normalize(pMat[3]),
|
||||
normalize(pMat[4]),
|
||||
normalize(pMat[5]) );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateCTM(GfxState* state,
|
||||
double, double,
|
||||
double, double,
|
||||
double, double)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
const double* const pMat = state->getCTM();
|
||||
assert(pMat);
|
||||
|
||||
printf( "updateCtm %f %f %f %f %f %f\n",
|
||||
normalize(pMat[0]),
|
||||
normalize(pMat[2]),
|
||||
normalize(pMat[1]),
|
||||
normalize(pMat[3]),
|
||||
normalize(pMat[4]),
|
||||
normalize(pMat[5]) );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateLineDash(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
double* dashArray; int arrayLen; double startOffset;
|
||||
state->getLineDash(&dashArray, &arrayLen, &startOffset);
|
||||
|
||||
printf( "updateLineDash" );
|
||||
if( arrayLen && dashArray )
|
||||
{
|
||||
printf( " %f %d", normalize(startOffset), arrayLen );
|
||||
for( int i=0; i<arrayLen; ++i )
|
||||
printf( " %f", normalize(*dashArray++) );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateFlatness(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
printf( "updateFlatness %d\n", state->getFlatness() );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateLineJoin(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
printf( "updateLineJoin %d\n", state->getLineJoin() );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateLineCap(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
printf( "updateLineCap %d\n", state->getLineCap() );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateMiterLimit(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
printf( "updateMiterLimit %f\n", normalize(state->getMiterLimit()) );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateLineWidth(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
printf( "updateLineWidth %f\n", normalize(state->getLineWidth()) );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateFillColor(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
GfxRGB aRGB;
|
||||
state->getFillRGB( &aRGB );
|
||||
|
||||
printf( "updateFillColor %f %f %f %f\n",
|
||||
normalize(colToDbl(aRGB.r)),
|
||||
normalize(colToDbl(aRGB.g)),
|
||||
normalize(colToDbl(aRGB.b)),
|
||||
normalize(state->getFillOpacity()) );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateStrokeColor(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
GfxRGB aRGB;
|
||||
state->getStrokeRGB( &aRGB );
|
||||
|
||||
printf( "updateStrokeColor %f %f %f %f\n",
|
||||
normalize(colToDbl(aRGB.r)),
|
||||
normalize(colToDbl(aRGB.g)),
|
||||
normalize(colToDbl(aRGB.b)),
|
||||
normalize(state->getFillOpacity()) );
|
||||
}
|
||||
|
||||
void PDFOutDev::updateFillOpacity(GfxState *state)
|
||||
{
|
||||
updateFillColor(state);
|
||||
}
|
||||
|
||||
void PDFOutDev::updateStrokeOpacity(GfxState *state)
|
||||
{
|
||||
updateStrokeColor(state);
|
||||
}
|
||||
|
||||
void PDFOutDev::updateBlendMode(GfxState*)
|
||||
{
|
||||
}
|
||||
|
||||
void PDFOutDev::updateFont(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
GfxFont *gfxFont = state->getFont();
|
||||
if( gfxFont )
|
||||
{
|
||||
FontAttributes aFont;
|
||||
int nEmbedSize=0;
|
||||
|
||||
Ref* pID = gfxFont->getID();
|
||||
// TODO(Q3): Portability problem
|
||||
long long fontID = (long long)pID->gen << 32 | (long long)pID->num;
|
||||
std::hash_map< long long, FontAttributes >::const_iterator it =
|
||||
m_aFontMap.find( fontID );
|
||||
if( it == m_aFontMap.end() )
|
||||
{
|
||||
nEmbedSize = parseFont( fontID, gfxFont, state );
|
||||
it = m_aFontMap.find( fontID );
|
||||
}
|
||||
|
||||
printf( "updateFont" );
|
||||
if( it != m_aFontMap.end() )
|
||||
{
|
||||
// conflating this with printf below crashes under Windoze
|
||||
printf( " %lld", fontID );
|
||||
|
||||
aFont = it->second;
|
||||
printf( " %d %d %d %d %f %d %s",
|
||||
aFont.isEmbedded,
|
||||
aFont.isBold,
|
||||
aFont.isItalic,
|
||||
aFont.isUnderline,
|
||||
normalize(state->getTransformedFontSize()),
|
||||
nEmbedSize,
|
||||
escapeLineFeed(aFont.familyName.getCString()) );
|
||||
}
|
||||
printf( "\n" );
|
||||
|
||||
if( nEmbedSize )
|
||||
writeFontFile(gfxFont);
|
||||
}
|
||||
}
|
||||
|
||||
void PDFOutDev::stroke(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
printf( "strokePath" );
|
||||
printPath( state->getPath() );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
void PDFOutDev::fill(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
printf( "fillPath" );
|
||||
printPath( state->getPath() );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
void PDFOutDev::eoFill(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
printf( "eoFillPath" );
|
||||
printPath( state->getPath() );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
void PDFOutDev::clip(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
printf( "clipPath" );
|
||||
printPath( state->getPath() );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
void PDFOutDev::eoClip(GfxState *state)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
printf( "eoClipPath" );
|
||||
printPath( state->getPath() );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
/** Output one glyph
|
||||
|
||||
|
||||
@param dx
|
||||
horizontal skip for character (already scaled with font size) +
|
||||
inter-char space: cursor is shifted by this amount for next char
|
||||
|
||||
@param dy
|
||||
vertical skip for character (zero for horizontal writing mode):
|
||||
cursor is shifted by this amount for next char
|
||||
|
||||
@param originX
|
||||
local offset of character (zero for horizontal writing mode). not
|
||||
taken into account for output pos updates. Used for vertical writing.
|
||||
|
||||
@param originY
|
||||
local offset of character (zero for horizontal writing mode). not
|
||||
taken into account for output pos updates. Used for vertical writing.
|
||||
*/
|
||||
void PDFOutDev::drawChar(GfxState *state, double x, double y,
|
||||
double dx, double dy,
|
||||
double originX, double originY,
|
||||
CharCode, int /*nBytes*/, Unicode *u, int uLen)
|
||||
{
|
||||
assert(state);
|
||||
|
||||
if( u == NULL )
|
||||
return;
|
||||
|
||||
// normalize coordinates: correct from baseline-relative to upper
|
||||
// left corner of glyphs
|
||||
double x2(0.0), y2(0.0);
|
||||
state->textTransformDelta( 0.0,
|
||||
state->getFont()->getAscent(),
|
||||
&x2, &y2 );
|
||||
const double fFontSize(state->getFontSize());
|
||||
x += x2*fFontSize;
|
||||
y += y2*fFontSize;
|
||||
|
||||
const double aPositionX(x-originX);
|
||||
const double aPositionY(y-originY);
|
||||
// TODO(F2): use leading here, when set
|
||||
const double nWidth(dx != 0.0 ? dx : fFontSize);
|
||||
const double nHeight(dy != 0.0 ? dy : fFontSize);
|
||||
|
||||
const double* pTextMat=state->getTextMat();
|
||||
printf( "drawChar %f %f %f %f %f %f %f %f ",
|
||||
normalize(aPositionX),
|
||||
normalize(aPositionY),
|
||||
normalize(aPositionX+nWidth),
|
||||
normalize(aPositionY-nHeight),
|
||||
normalize(pTextMat[0]),
|
||||
normalize(pTextMat[2]),
|
||||
normalize(pTextMat[1]),
|
||||
normalize(pTextMat[3]) );
|
||||
|
||||
// silence spurious warning
|
||||
(void)&mapUCS2;
|
||||
|
||||
char buf[9];
|
||||
for( int i=0; i<uLen; ++i )
|
||||
{
|
||||
buf[ m_pUtf8Map->mapUnicode(u[i], buf, sizeof(buf)-1) ] = 0;
|
||||
printf( "%s", escapeLineFeed(buf) );
|
||||
}
|
||||
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
void PDFOutDev::drawString(GfxState*, GooString* /*s*/)
|
||||
{
|
||||
// TODO(F3): NYI
|
||||
}
|
||||
|
||||
void PDFOutDev::endTextObject(GfxState*)
|
||||
{
|
||||
printf( "endTextObject\n" );
|
||||
}
|
||||
|
||||
void PDFOutDev::drawImageMask(GfxState*, Object*, Stream* str,
|
||||
int width, int height, GBool invert,
|
||||
GBool /*inlineImg*/ )
|
||||
{
|
||||
OutputBuffer aBuf; initBuf(aBuf);
|
||||
|
||||
printf( "drawMask %d %d %d", width, height, invert );
|
||||
writeMaskLF(aBuf, str, width, height);
|
||||
writeBinaryBuffer(aBuf);
|
||||
}
|
||||
|
||||
void PDFOutDev::drawImage(GfxState*, Object*, Stream* str,
|
||||
int width, int height, GfxImageColorMap* colorMap,
|
||||
int* maskColors, GBool /*inlineImg*/ )
|
||||
{
|
||||
OutputBuffer aBuf; initBuf(aBuf);
|
||||
OutputBuffer aMaskBuf;
|
||||
|
||||
printf( "drawImage %d %d", width, height );
|
||||
|
||||
if( maskColors )
|
||||
{
|
||||
// write mask colors. nBytes must be even - first half is
|
||||
// lower bound values, second half upper bound values
|
||||
if( colorMap->getColorSpace()->getMode() == csIndexed )
|
||||
{
|
||||
aMaskBuf.push_back( (char)maskColors[0] );
|
||||
aMaskBuf.push_back( (char)maskColors[gfxColorMaxComps] );
|
||||
}
|
||||
else
|
||||
{
|
||||
GfxRGB aMinRGB;
|
||||
colorMap->getColorSpace()->getRGB(
|
||||
(GfxColor*)maskColors,
|
||||
&aMinRGB );
|
||||
|
||||
GfxRGB aMaxRGB;
|
||||
colorMap->getColorSpace()->getRGB(
|
||||
(GfxColor*)maskColors+gfxColorMaxComps,
|
||||
&aMaxRGB );
|
||||
|
||||
aMaskBuf.push_back( colToByte(aMinRGB.r) );
|
||||
aMaskBuf.push_back( colToByte(aMinRGB.g) );
|
||||
aMaskBuf.push_back( colToByte(aMinRGB.b) );
|
||||
aMaskBuf.push_back( colToByte(aMaxRGB.r) );
|
||||
aMaskBuf.push_back( colToByte(aMaxRGB.g) );
|
||||
aMaskBuf.push_back( colToByte(aMaxRGB.b) );
|
||||
}
|
||||
}
|
||||
|
||||
printf( " %d", aMaskBuf.size() );
|
||||
writeImageLF( aBuf, str, width, height, colorMap );
|
||||
writeBinaryBuffer(aBuf);
|
||||
writeBinaryBuffer(aMaskBuf);
|
||||
}
|
||||
|
||||
void PDFOutDev::drawMaskedImage(GfxState*, Object*, Stream* str,
|
||||
int width, int height,
|
||||
GfxImageColorMap* colorMap,
|
||||
Stream* maskStr,
|
||||
int maskWidth, int maskHeight,
|
||||
GBool maskInvert)
|
||||
{
|
||||
OutputBuffer aBuf; initBuf(aBuf);
|
||||
OutputBuffer aMaskBuf; initBuf(aMaskBuf);
|
||||
|
||||
printf( "drawMaskedImage %d %d %d %d %d", width, height, maskWidth, maskHeight, maskInvert );
|
||||
writeImage( aBuf, str, width, height, colorMap );
|
||||
writeMaskLF( aMaskBuf, maskStr, width, height );
|
||||
writeBinaryBuffer(aBuf);
|
||||
writeBinaryBuffer(aMaskBuf);
|
||||
}
|
||||
|
||||
void PDFOutDev::drawSoftMaskedImage(GfxState*, Object*, Stream* str,
|
||||
int width, int height,
|
||||
GfxImageColorMap* colorMap,
|
||||
Stream* maskStr,
|
||||
int maskWidth, int maskHeight,
|
||||
GfxImageColorMap* maskColorMap )
|
||||
{
|
||||
OutputBuffer aBuf; initBuf(aBuf);
|
||||
OutputBuffer aMaskBuf; initBuf(aMaskBuf);
|
||||
|
||||
printf( "drawSoftMaskedImage %d %d %d %d", width, height, maskWidth, maskHeight );
|
||||
writeImage( aBuf, str, width, height, colorMap );
|
||||
writeImageLF( aMaskBuf, maskStr, maskWidth, maskHeight, maskColorMap );
|
||||
writeBinaryBuffer(aBuf);
|
||||
writeBinaryBuffer(aMaskBuf);
|
||||
}
|
||||
|
||||
void PDFOutDev::setPageNum( int nNumPages )
|
||||
{
|
||||
// TODO(F3): printf might format int locale-dependent!
|
||||
printf("setPageNum %d\n", nNumPages);
|
||||
}
|
||||
|
||||
}
|
290
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
Normal file
290
sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx
Normal file
|
@ -0,0 +1,290 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: pdfioutdev_gpl.hxx,v $
|
||||
*
|
||||
* $Revision: 1.1.2.1 $
|
||||
*
|
||||
* last change: $Author: cmc $ $Date: 2008/08/25 16:17:55 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU General Public License Version 2.
|
||||
*
|
||||
*
|
||||
* GNU General Public License, version 2
|
||||
* =============================================
|
||||
* Copyright 2005 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef INCLUDED_PDFI_OUTDEV_HXX
|
||||
#define INCLUDED_PDFI_OUTDEV_HXX
|
||||
|
||||
#if defined __GNUC__
|
||||
#pragma GCC system_header
|
||||
#elif defined __SUNPRO_CC
|
||||
#pragma disable_warn
|
||||
#elif defined _MSC_VER
|
||||
#pragma warning(push, 1)
|
||||
#endif
|
||||
|
||||
#include "GfxState.h"
|
||||
#include "GfxFont.h"
|
||||
#include "UnicodeMap.h"
|
||||
#include "Link.h"
|
||||
#include "Object.h"
|
||||
#include "OutputDev.h"
|
||||
#ifndef SYSTEM_POPPLER
|
||||
# include "parseargs.h"
|
||||
#endif
|
||||
#include "GlobalParams.h"
|
||||
#include "PDFDoc.h"
|
||||
|
||||
#if defined __SUNPRO_CC
|
||||
#pragma enable_warn
|
||||
#elif defined _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#include <hash_map>
|
||||
|
||||
class GfxPath;
|
||||
class GfxFont;
|
||||
class PDFDoc;
|
||||
#ifndef SYSTEM_POPPLER
|
||||
typedef GString GooString;
|
||||
#endif
|
||||
|
||||
namespace pdfi
|
||||
{
|
||||
struct FontAttributes
|
||||
{
|
||||
FontAttributes( const GooString& familyName_,
|
||||
bool isEmbedded_,
|
||||
bool isBold_,
|
||||
bool isItalic_,
|
||||
bool isUnderline_,
|
||||
double size_ ) :
|
||||
familyName(),
|
||||
isEmbedded(isEmbedded_),
|
||||
isBold(isBold_),
|
||||
isItalic(isItalic_),
|
||||
isUnderline(isUnderline_),
|
||||
size(size_)
|
||||
{
|
||||
familyName.append(const_cast<GooString*>(&familyName_));
|
||||
}
|
||||
|
||||
FontAttributes() :
|
||||
familyName(),
|
||||
isEmbedded(false),
|
||||
isBold(false),
|
||||
isItalic(false),
|
||||
isUnderline(false),
|
||||
size(0.0)
|
||||
{}
|
||||
|
||||
// xdpf goo stuff is so totally borked...
|
||||
// ...need to hand-code assignment
|
||||
FontAttributes( const FontAttributes& rSrc ) :
|
||||
familyName(),
|
||||
isEmbedded(rSrc.isEmbedded),
|
||||
isBold(rSrc.isBold),
|
||||
isItalic(rSrc.isItalic),
|
||||
isUnderline(rSrc.isUnderline),
|
||||
size(rSrc.size)
|
||||
{
|
||||
familyName.append(const_cast<GooString*>(&rSrc.familyName));
|
||||
}
|
||||
|
||||
FontAttributes& operator=( const FontAttributes& rSrc )
|
||||
{
|
||||
familyName.clear();
|
||||
familyName.append(const_cast<GooString*>(&rSrc.familyName));
|
||||
|
||||
isEmbedded = rSrc.isEmbedded;
|
||||
isBold = rSrc.isBold;
|
||||
isItalic = rSrc.isItalic;
|
||||
isUnderline = rSrc.isUnderline;
|
||||
size = rSrc.size;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const FontAttributes& rFont) const
|
||||
{
|
||||
return const_cast<GooString*>(&familyName)->cmp(
|
||||
const_cast<GooString*>(&rFont.familyName))==0 &&
|
||||
isEmbedded == rFont.isEmbedded &&
|
||||
isBold == rFont.isBold &&
|
||||
isItalic == rFont.isItalic &&
|
||||
isUnderline == rFont.isUnderline &&
|
||||
size == rFont.size;
|
||||
}
|
||||
|
||||
GooString familyName;
|
||||
bool isEmbedded;
|
||||
bool isBold;
|
||||
bool isItalic;
|
||||
bool isUnderline;
|
||||
double size;
|
||||
};
|
||||
|
||||
class PDFOutDev : public OutputDev
|
||||
{
|
||||
// not owned by this class
|
||||
PDFDoc* m_pDoc;
|
||||
mutable std::hash_map< long long,
|
||||
FontAttributes > m_aFontMap;
|
||||
UnicodeMap* m_pUtf8Map;
|
||||
|
||||
int parseFont( long long nNewId, GfxFont* pFont, GfxState* state ) const;
|
||||
void writeFontFile( GfxFont* gfxFont ) const;
|
||||
void printPath( GfxPath* pPath ) const;
|
||||
|
||||
public:
|
||||
explicit PDFOutDev( PDFDoc* pDoc );
|
||||
|
||||
//----- get info about output device
|
||||
|
||||
// Does this device use upside-down coordinates?
|
||||
// (Upside-down means (0,0) is the top left corner of the page.)
|
||||
virtual GBool upsideDown() { return gTrue; }
|
||||
|
||||
// Does this device use drawChar() or drawString()?
|
||||
virtual GBool useDrawChar() { return gTrue; }
|
||||
|
||||
// Does this device use beginType3Char/endType3Char? Otherwise,
|
||||
// text in Type 3 fonts will be drawn with drawChar/drawString.
|
||||
virtual GBool interpretType3Chars() { return gFalse; }
|
||||
|
||||
// Does this device need non-text content?
|
||||
virtual GBool needNonText() { return gTrue; }
|
||||
|
||||
//----- initialization and control
|
||||
|
||||
// Set default transform matrix.
|
||||
virtual void setDefaultCTM(double *ctm);
|
||||
|
||||
// Start a page.
|
||||
virtual void startPage(int pageNum, GfxState *state);
|
||||
|
||||
// End a page.
|
||||
virtual void endPage();
|
||||
|
||||
// Dump page contents to display.
|
||||
// virtual void dump() {}
|
||||
|
||||
//----- coordinate conversion
|
||||
|
||||
// Convert between device and user coordinates.
|
||||
// virtual void cvtDevToUser(double dx, double dy, double *ux, double *uy);
|
||||
// virtual void cvtUserToDev(double ux, double uy, int *dx, int *dy);
|
||||
|
||||
//----- link borders
|
||||
virtual void processLink(Link *link, Catalog *catalog);
|
||||
|
||||
//----- save/restore graphics state
|
||||
virtual void saveState(GfxState *state);
|
||||
virtual void restoreState(GfxState *state);
|
||||
|
||||
//----- update graphics state
|
||||
// virtual void updateAll(GfxState *state);
|
||||
virtual void updateCTM(GfxState *state, double m11, double m12,
|
||||
double m21, double m22, double m31, double m32);
|
||||
virtual void updateLineDash(GfxState *state);
|
||||
virtual void updateFlatness(GfxState *state);
|
||||
virtual void updateLineJoin(GfxState *state);
|
||||
virtual void updateLineCap(GfxState *state);
|
||||
virtual void updateMiterLimit(GfxState *state);
|
||||
virtual void updateLineWidth(GfxState *state);
|
||||
virtual void updateFillColor(GfxState *state);
|
||||
virtual void updateStrokeColor(GfxState *state);
|
||||
virtual void updateFillOpacity(GfxState *state);
|
||||
virtual void updateStrokeOpacity(GfxState *state);
|
||||
virtual void updateBlendMode(GfxState *state);
|
||||
|
||||
//----- update text state
|
||||
virtual void updateFont(GfxState *state);
|
||||
// virtual void updateTextMat(GfxState *state);
|
||||
// virtual void updateCharSpace(GfxState *state) {}
|
||||
// virtual void updateRender(GfxState *state) {}
|
||||
// virtual void updateRise(GfxState *state) {}
|
||||
// virtual void updateWordSpace(GfxState *state) {}
|
||||
// virtual void updateHorizScaling(GfxState *state) {}
|
||||
// virtual void updateTextPos(GfxState *state) {}
|
||||
// virtual void updateTextShift(GfxState *state, double shift) {}
|
||||
|
||||
//----- path painting
|
||||
virtual void stroke(GfxState *state);
|
||||
virtual void fill(GfxState *state);
|
||||
virtual void eoFill(GfxState *state);
|
||||
|
||||
//----- path clipping
|
||||
virtual void clip(GfxState *state);
|
||||
virtual void eoClip(GfxState *state);
|
||||
|
||||
//----- text drawing
|
||||
virtual void drawChar(GfxState *state, double x, double y,
|
||||
double dx, double dy,
|
||||
double originX, double originY,
|
||||
CharCode code, int nBytes, Unicode *u, int uLen);
|
||||
virtual void drawString(GfxState *state, GooString *s);
|
||||
virtual void endTextObject(GfxState *state);
|
||||
|
||||
//----- image drawing
|
||||
virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
|
||||
int width, int height, GBool invert,
|
||||
GBool inlineImg);
|
||||
virtual void drawImage(GfxState *state, Object *ref, Stream *str,
|
||||
int width, int height, GfxImageColorMap *colorMap,
|
||||
int *maskColors, GBool inlineImg);
|
||||
virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
|
||||
int width, int height,
|
||||
GfxImageColorMap *colorMap,
|
||||
Stream *maskStr, int maskWidth, int maskHeight,
|
||||
GBool maskInvert);
|
||||
virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
|
||||
int width, int height,
|
||||
GfxImageColorMap *colorMap,
|
||||
Stream *maskStr,
|
||||
int maskWidth, int maskHeight,
|
||||
GfxImageColorMap *maskColorMap);
|
||||
|
||||
//----- OPI functions
|
||||
// virtual void opiBegin(GfxState *state, Dict *opiDict);
|
||||
// virtual void opiEnd(GfxState *state, Dict *opiDict);
|
||||
|
||||
//----- Type 3 font operators
|
||||
// virtual void type3D0(GfxState *state, double wx, double wy) {}
|
||||
// virtual void type3D1(GfxState *state, double wx, double wy,
|
||||
// double llx, double lly, double urx, double ury) {}
|
||||
|
||||
//----- PostScript XObjects
|
||||
// virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
|
||||
|
||||
void setPageNum( int nNumPages );
|
||||
};
|
||||
}
|
||||
|
||||
extern FILE* g_binary_out;
|
||||
|
||||
#endif /* INCLUDED_PDFI_OUTDEV_HXX */
|
||||
|
204
sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
Normal file
204
sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx
Normal file
|
@ -0,0 +1,204 @@
|
|||
/*************************************************************************
|
||||
*
|
||||
* OpenOffice.org - a multi-platform office productivity suite
|
||||
*
|
||||
* $RCSfile: wrapper_gpl.cxx,v $
|
||||
*
|
||||
* $Revision: 1.1.2.1 $
|
||||
*
|
||||
* last change: $Author: cmc $ $Date: 2008/08/25 16:17:55 $
|
||||
*
|
||||
* The Contents of this file are made available subject to
|
||||
* the terms of GNU General Public License Version 2.
|
||||
*
|
||||
*
|
||||
* GNU General Public License, version 2
|
||||
* =============================================
|
||||
* Copyright 2005 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this program; if not, write to the Free
|
||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#include "pdfioutdev_gpl.hxx"
|
||||
//#include "SecurityHandler.h"
|
||||
#ifdef WNT
|
||||
# include <io.h>
|
||||
# include <fcntl.h> /*_O_BINARY*/
|
||||
#endif
|
||||
|
||||
FILE* g_binary_out=stderr;
|
||||
|
||||
#ifndef SYSTEM_POPPLER
|
||||
static char ownerPassword[33] = "\001";
|
||||
static char userPassword[33] = "\001";
|
||||
static char outputFile[256] = "\001";
|
||||
|
||||
static ArgDesc argDesc[] = {
|
||||
{"-f", argString, outputFile, sizeof(outputFile),
|
||||
"output file for binary streams"},
|
||||
{"-opw", argString, ownerPassword, sizeof(ownerPassword),
|
||||
"owner password (for encrypted files)"},
|
||||
{"-upw", argString, userPassword, sizeof(userPassword),
|
||||
"user password (for encrypted files)"},
|
||||
{NULL, argString, NULL, 0, NULL }
|
||||
};
|
||||
#else
|
||||
static const char *ownerPassword = "\001";
|
||||
static const char *userPassword = "\001";
|
||||
static const char *outputFile = "\001";
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#ifndef SYSTEM_POPPLER
|
||||
// parse args; initialize to defaults
|
||||
if( !parseArgs(argDesc, &argc, argv) )
|
||||
return 1;
|
||||
#else
|
||||
int k = 0;
|
||||
while (k < argc)
|
||||
{
|
||||
if (!strcmp(argv[k], "-f"))
|
||||
{
|
||||
outputFile = argv[k+1];
|
||||
--argc;
|
||||
for (int j = k; j < argc; ++j)
|
||||
argv[j] = argv[j+1];
|
||||
}
|
||||
else if (!strcmp(argv[k], "-opw"))
|
||||
{
|
||||
ownerPassword = argv[k+1];
|
||||
--argc;
|
||||
for (int j = k; j < argc; ++j)
|
||||
argv[j] = argv[j+1];
|
||||
}
|
||||
else if (!strcmp(argv[k], "-upw"))
|
||||
{
|
||||
userPassword = argv[k+1];
|
||||
--argc;
|
||||
for (int j = k; j < argc; ++j)
|
||||
argv[j] = argv[j+1];
|
||||
}
|
||||
++k;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( argc < 2 )
|
||||
return 1;
|
||||
|
||||
// read config file
|
||||
globalParams = new GlobalParams(
|
||||
#ifndef SYSTEM_POPPLER
|
||||
""
|
||||
#endif
|
||||
);
|
||||
globalParams->setErrQuiet(gTrue);
|
||||
#if !defined(SYSTEM_POPPLER) || defined(_MSC_VER)
|
||||
globalParams->setupBaseFonts(NULL);
|
||||
#endif
|
||||
|
||||
// PDFDoc takes over ownership for all strings below
|
||||
GooString* pFileName = new GooString(argv[1]);
|
||||
GooString* pTempErrFileName = new GooString("_err.pdf");
|
||||
GooString* pTempErrFileNamePath = new GooString(argv[0]);
|
||||
|
||||
GooString* pErrFileName = new GooString(pTempErrFileNamePath,pTempErrFileName);
|
||||
|
||||
|
||||
// check for password string(s)
|
||||
GooString* pOwnerPasswordStr(
|
||||
ownerPassword[0] != '\001' ? new GooString(ownerPassword)
|
||||
: (GooString *)NULL );
|
||||
GooString* pUserPasswordStr(
|
||||
userPassword[0] != '\001' ? new GooString(userPassword)
|
||||
: (GooString *)NULL );
|
||||
if( outputFile[0] != '\001' )
|
||||
g_binary_out = fopen(outputFile,"wb");
|
||||
|
||||
#ifdef WNT
|
||||
// Win actually modifies output for O_TEXT file mode, so need to
|
||||
// revert to binary here
|
||||
_setmode( _fileno( g_binary_out ), _O_BINARY );
|
||||
#endif
|
||||
|
||||
PDFDoc aDoc( pFileName,
|
||||
pOwnerPasswordStr,
|
||||
pUserPasswordStr );
|
||||
|
||||
PDFDoc aErrDoc( pErrFileName,
|
||||
pOwnerPasswordStr,
|
||||
pUserPasswordStr );
|
||||
|
||||
|
||||
// Check various permissions.
|
||||
if ( !aDoc.isOk()||
|
||||
!aDoc.okToPrint() ||
|
||||
!aDoc.okToChange()||
|
||||
!aDoc.okToCopy()||
|
||||
!aDoc.okToAddNotes()||
|
||||
(userPassword[0] != '\001')||
|
||||
(ownerPassword[0] != '\001')
|
||||
)
|
||||
{
|
||||
pdfi::PDFOutDev* pOutDev( new pdfi::PDFOutDev(&aErrDoc) );
|
||||
|
||||
const int nPages = aErrDoc.isOk() ? aErrDoc.getNumPages() : 0;
|
||||
|
||||
// tell receiver early - needed for proper progress calculation
|
||||
pOutDev->setPageNum( nPages );
|
||||
|
||||
// virtual resolution of the PDF OutputDev in dpi
|
||||
static const int PDFI_OUTDEV_RESOLUTION=7200;
|
||||
|
||||
// do the conversion
|
||||
for( int i=1; i<=nPages; ++i )
|
||||
{
|
||||
aErrDoc.displayPage( pOutDev,
|
||||
i,
|
||||
PDFI_OUTDEV_RESOLUTION,
|
||||
PDFI_OUTDEV_RESOLUTION,
|
||||
0, gTrue, gTrue, gTrue );
|
||||
aErrDoc.processLinks( pOutDev, i );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pdfi::PDFOutDev* pOutDev( new pdfi::PDFOutDev(&aDoc) );
|
||||
|
||||
// tell receiver early - needed for proper progress calculation
|
||||
pOutDev->setPageNum( aDoc.getNumPages() );
|
||||
|
||||
// virtual resolution of the PDF OutputDev in dpi
|
||||
static const int PDFI_OUTDEV_RESOLUTION=7200;
|
||||
|
||||
// do the conversion
|
||||
const int nPages = aDoc.getNumPages();
|
||||
for( int i=1; i<=nPages; ++i )
|
||||
{
|
||||
aDoc.displayPage( pOutDev,
|
||||
i,
|
||||
PDFI_OUTDEV_RESOLUTION,
|
||||
PDFI_OUTDEV_RESOLUTION,
|
||||
0, gTrue, gTrue, gTrue );
|
||||
aDoc.processLinks( pOutDev, i );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in a new issue