pdf2json 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +9 -0
- data/bin/.gitkeep +0 -0
- data/ext/extconf.rb +30 -0
- data/lib/pdf2json.rb +8 -0
- data/pdf2json-0.52-source/AUTHORS +24 -0
- data/pdf2json-0.52-source/CHANGES +11 -0
- data/pdf2json-0.52-source/Makefile +84 -0
- data/pdf2json-0.52-source/Makefile.in +84 -0
- data/pdf2json-0.52-source/aclocal.m4 +274 -0
- data/pdf2json-0.52-source/aconf-win32.h +86 -0
- data/pdf2json-0.52-source/aconf.h +42 -0
- data/pdf2json-0.52-source/aconf.h.in +41 -0
- data/pdf2json-0.52-source/autom4te.cache/output.0 +6908 -0
- data/pdf2json-0.52-source/autom4te.cache/requests +76 -0
- data/pdf2json-0.52-source/autom4te.cache/traces.0 +466 -0
- data/pdf2json-0.52-source/config.log +1259 -0
- data/pdf2json-0.52-source/config.status +1050 -0
- data/pdf2json-0.52-source/configure +6908 -0
- data/pdf2json-0.52-source/configure.ac +93 -0
- data/pdf2json-0.52-source/doc/pdffonts.1 +130 -0
- data/pdf2json-0.52-source/doc/pdffonts.cat +107 -0
- data/pdf2json-0.52-source/doc/pdffonts.hlp +117 -0
- data/pdf2json-0.52-source/doc/pdfimages.1 +102 -0
- data/pdf2json-0.52-source/doc/pdfimages.cat +92 -0
- data/pdf2json-0.52-source/doc/pdfimages.hlp +101 -0
- data/pdf2json-0.52-source/doc/pdfinfo.1 +158 -0
- data/pdf2json-0.52-source/doc/pdfinfo.cat +119 -0
- data/pdf2json-0.52-source/doc/pdfinfo.hlp +129 -0
- data/pdf2json-0.52-source/doc/pdftoppm.1 +115 -0
- data/pdf2json-0.52-source/doc/pdftoppm.cat +105 -0
- data/pdf2json-0.52-source/doc/pdftoppm.hlp +114 -0
- data/pdf2json-0.52-source/doc/pdftops.1 +229 -0
- data/pdf2json-0.52-source/doc/pdftops.cat +221 -0
- data/pdf2json-0.52-source/doc/pdftops.hlp +231 -0
- data/pdf2json-0.52-source/doc/pdftotext.1 +137 -0
- data/pdf2json-0.52-source/doc/pdftotext.cat +120 -0
- data/pdf2json-0.52-source/doc/pdftotext.hlp +133 -0
- data/pdf2json-0.52-source/doc/sample-xpdfrc +91 -0
- data/pdf2json-0.52-source/doc/xpdf.1 +513 -0
- data/pdf2json-0.52-source/doc/xpdf.cat +476 -0
- data/pdf2json-0.52-source/doc/xpdf.hlp +489 -0
- data/pdf2json-0.52-source/doc/xpdfrc.5 +480 -0
- data/pdf2json-0.52-source/doc/xpdfrc.cat +474 -0
- data/pdf2json-0.52-source/doc/xpdfrc.hlp +479 -0
- data/pdf2json-0.52-source/fofi/.DS_Store +0 -0
- data/pdf2json-0.52-source/fofi/FoFiBase.cc +156 -0
- data/pdf2json-0.52-source/fofi/FoFiBase.h +57 -0
- data/pdf2json-0.52-source/fofi/FoFiBase.o +0 -0
- data/pdf2json-0.52-source/fofi/FoFiEncodings.cc +994 -0
- data/pdf2json-0.52-source/fofi/FoFiEncodings.h +36 -0
- data/pdf2json-0.52-source/fofi/FoFiEncodings.o +0 -0
- data/pdf2json-0.52-source/fofi/FoFiTrueType.cc +2027 -0
- data/pdf2json-0.52-source/fofi/FoFiTrueType.h +174 -0
- data/pdf2json-0.52-source/fofi/FoFiTrueType.o +0 -0
- data/pdf2json-0.52-source/fofi/FoFiType1.cc +252 -0
- data/pdf2json-0.52-source/fofi/FoFiType1.h +59 -0
- data/pdf2json-0.52-source/fofi/FoFiType1.o +0 -0
- data/pdf2json-0.52-source/fofi/FoFiType1C.cc +2603 -0
- data/pdf2json-0.52-source/fofi/FoFiType1C.h +233 -0
- data/pdf2json-0.52-source/fofi/FoFiType1C.o +0 -0
- data/pdf2json-0.52-source/fofi/Makefile +70 -0
- data/pdf2json-0.52-source/fofi/Makefile.dep +0 -0
- data/pdf2json-0.52-source/fofi/Makefile.in +70 -0
- data/pdf2json-0.52-source/fofi/libfofi.a +0 -0
- data/pdf2json-0.52-source/fofi/vms_make.com +0 -0
- data/pdf2json-0.52-source/freetype.win32/.DS_Store +0 -0
- data/pdf2json-0.52-source/freetype.win32/include/.DS_Store +0 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftconfig.h +528 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftheader.h +780 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftmodule.h +32 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftoption.h +733 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/config/ftstdlib.h +173 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/freetype.h +3919 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftadvanc.h +179 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftbbox.h +94 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftbdf.h +209 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftbitmap.h +227 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftcache.h +1128 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftchapters.h +103 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftcid.h +166 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/fterrdef.h +244 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/fterrors.h +206 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftgasp.h +120 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftglyph.h +613 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftgxval.h +358 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftgzip.h +102 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftimage.h +1313 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftincrem.h +353 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftlcdfil.h +213 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftlist.h +277 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftlzw.h +99 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmac.h +274 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmm.h +378 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmodapi.h +483 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftmoderr.h +155 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftotval.h +203 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftoutln.h +537 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftpfr.h +172 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftrender.h +230 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsizes.h +159 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsnames.h +200 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftstroke.h +716 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsynth.h +80 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftsystem.h +347 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/fttrigon.h +350 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/fttypes.h +588 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftwinfnt.h +274 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ftxf86.h +83 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/autohint.h +231 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftcalc.h +179 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftdebug.h +250 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftdriver.h +422 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftgloadr.h +168 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftmemory.h +380 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftobjs.h +1428 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftpic.h +67 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftrfork.h +196 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftserv.h +620 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftstream.h +539 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/fttrace.h +139 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/ftvalid.h +150 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/internal.h +51 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/pcftypes.h +56 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/psaux.h +873 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/pshints.h +712 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svbdf.h +77 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svcid.h +83 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svgldict.h +82 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svgxval.h +72 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svkern.h +51 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svmm.h +104 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svotval.h +55 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpfr.h +66 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpostnm.h +79 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpscmap.h +164 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svpsinfo.h +92 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svsfnt.h +102 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svttcmap.h +106 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svtteng.h +53 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svttglyf.h +67 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svwinfnt.h +50 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/services/svxf86nm.h +55 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/sfnt.h +897 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/t1types.h +270 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/internal/tttypes.h +1543 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/t1tables.h +504 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ttnameid.h +1247 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/tttables.h +759 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/tttags.h +107 -0
- data/pdf2json-0.52-source/freetype.win32/include/freetype/ttunpat.h +59 -0
- data/pdf2json-0.52-source/freetype.win32/include/ft2build.h +39 -0
- data/pdf2json-0.52-source/freetype.win32/lib/freetype_a.lib +0 -0
- data/pdf2json-0.52-source/goo/.DS_Store +0 -0
- data/pdf2json-0.52-source/goo/FixedPoint.cc +118 -0
- data/pdf2json-0.52-source/goo/FixedPoint.h +155 -0
- data/pdf2json-0.52-source/goo/FixedPoint.o +0 -0
- data/pdf2json-0.52-source/goo/GHash.cc +380 -0
- data/pdf2json-0.52-source/goo/GHash.h +78 -0
- data/pdf2json-0.52-source/goo/GHash.o +0 -0
- data/pdf2json-0.52-source/goo/GList.cc +97 -0
- data/pdf2json-0.52-source/goo/GList.h +96 -0
- data/pdf2json-0.52-source/goo/GList.o +0 -0
- data/pdf2json-0.52-source/goo/GMutex.h +49 -0
- data/pdf2json-0.52-source/goo/GString.cc +724 -0
- data/pdf2json-0.52-source/goo/GString.cc.fixed +718 -0
- data/pdf2json-0.52-source/goo/GString.h +136 -0
- data/pdf2json-0.52-source/goo/GString.o +0 -0
- data/pdf2json-0.52-source/goo/ImgWriter.o +0 -0
- data/pdf2json-0.52-source/goo/JpegWriter.o +0 -0
- data/pdf2json-0.52-source/goo/Makefile +72 -0
- data/pdf2json-0.52-source/goo/Makefile.dep +0 -0
- data/pdf2json-0.52-source/goo/Makefile.in +72 -0
- data/pdf2json-0.52-source/goo/PNGWriter.o +0 -0
- data/pdf2json-0.52-source/goo/gfile.cc +731 -0
- data/pdf2json-0.52-source/goo/gfile.h +138 -0
- data/pdf2json-0.52-source/goo/gfile.o +0 -0
- data/pdf2json-0.52-source/goo/gmem.cc +264 -0
- data/pdf2json-0.52-source/goo/gmem.h +79 -0
- data/pdf2json-0.52-source/goo/gmem.o +0 -0
- data/pdf2json-0.52-source/goo/gmempp.cc +32 -0
- data/pdf2json-0.52-source/goo/gmempp.o +0 -0
- data/pdf2json-0.52-source/goo/gtypes.h +29 -0
- data/pdf2json-0.52-source/goo/libGoo.a +0 -0
- data/pdf2json-0.52-source/goo/parseargs.c +190 -0
- data/pdf2json-0.52-source/goo/parseargs.h +71 -0
- data/pdf2json-0.52-source/goo/parseargs.o +0 -0
- data/pdf2json-0.52-source/goo/vms_directory.c +214 -0
- data/pdf2json-0.52-source/goo/vms_dirent.h +67 -0
- data/pdf2json-0.52-source/goo/vms_make.com +82 -0
- data/pdf2json-0.52-source/goo/vms_sys_dirent.h +54 -0
- data/pdf2json-0.52-source/goo/vms_unix_time.h +102 -0
- data/pdf2json-0.52-source/goo/vms_unix_times.c +42 -0
- data/pdf2json-0.52-source/goo/vms_unlink.c +22 -0
- data/pdf2json-0.52-source/ms_make.bat +199 -0
- data/pdf2json-0.52-source/splash/.DS_Store +0 -0
- data/pdf2json-0.52-source/splash/Makefile +103 -0
- data/pdf2json-0.52-source/splash/Makefile.dep +0 -0
- data/pdf2json-0.52-source/splash/Makefile.in +103 -0
- data/pdf2json-0.52-source/splash/Splash.cc +3310 -0
- data/pdf2json-0.52-source/splash/Splash.h +293 -0
- data/pdf2json-0.52-source/splash/Splash.o +0 -0
- data/pdf2json-0.52-source/splash/SplashBitmap.cc +188 -0
- data/pdf2json-0.52-source/splash/SplashBitmap.h +64 -0
- data/pdf2json-0.52-source/splash/SplashBitmap.o +0 -0
- data/pdf2json-0.52-source/splash/SplashClip.cc +382 -0
- data/pdf2json-0.52-source/splash/SplashClip.h +107 -0
- data/pdf2json-0.52-source/splash/SplashClip.o +0 -0
- data/pdf2json-0.52-source/splash/SplashErrorCodes.h +32 -0
- data/pdf2json-0.52-source/splash/SplashFTFont.cc +357 -0
- data/pdf2json-0.52-source/splash/SplashFTFont.h +58 -0
- data/pdf2json-0.52-source/splash/SplashFTFont.o +0 -0
- data/pdf2json-0.52-source/splash/SplashFTFontEngine.cc +179 -0
- data/pdf2json-0.52-source/splash/SplashFTFontEngine.h +65 -0
- data/pdf2json-0.52-source/splash/SplashFTFontEngine.o +0 -0
- data/pdf2json-0.52-source/splash/SplashFTFontFile.cc +114 -0
- data/pdf2json-0.52-source/splash/SplashFTFontFile.h +73 -0
- data/pdf2json-0.52-source/splash/SplashFTFontFile.o +0 -0
- data/pdf2json-0.52-source/splash/SplashFont.cc +176 -0
- data/pdf2json-0.52-source/splash/SplashFont.h +104 -0
- data/pdf2json-0.52-source/splash/SplashFont.o +0 -0
- data/pdf2json-0.52-source/splash/SplashFontEngine.cc +317 -0
- data/pdf2json-0.52-source/splash/SplashFontEngine.h +91 -0
- data/pdf2json-0.52-source/splash/SplashFontEngine.o +0 -0
- data/pdf2json-0.52-source/splash/SplashFontFile.cc +55 -0
- data/pdf2json-0.52-source/splash/SplashFontFile.h +60 -0
- data/pdf2json-0.52-source/splash/SplashFontFile.o +0 -0
- data/pdf2json-0.52-source/splash/SplashFontFileID.cc +23 -0
- data/pdf2json-0.52-source/splash/SplashFontFileID.h +30 -0
- data/pdf2json-0.52-source/splash/SplashFontFileID.o +0 -0
- data/pdf2json-0.52-source/splash/SplashGlyphBitmap.h +26 -0
- data/pdf2json-0.52-source/splash/SplashMath.h +89 -0
- data/pdf2json-0.52-source/splash/SplashPath.cc +184 -0
- data/pdf2json-0.52-source/splash/SplashPath.h +121 -0
- data/pdf2json-0.52-source/splash/SplashPath.o +0 -0
- data/pdf2json-0.52-source/splash/SplashPattern.cc +40 -0
- data/pdf2json-0.52-source/splash/SplashPattern.h +65 -0
- data/pdf2json-0.52-source/splash/SplashPattern.o +0 -0
- data/pdf2json-0.52-source/splash/SplashScreen.cc +383 -0
- data/pdf2json-0.52-source/splash/SplashScreen.h +56 -0
- data/pdf2json-0.52-source/splash/SplashScreen.o +0 -0
- data/pdf2json-0.52-source/splash/SplashState.cc +165 -0
- data/pdf2json-0.52-source/splash/SplashState.h +103 -0
- data/pdf2json-0.52-source/splash/SplashState.o +0 -0
- data/pdf2json-0.52-source/splash/SplashT1Font.cc +287 -0
- data/pdf2json-0.52-source/splash/SplashT1Font.h +57 -0
- data/pdf2json-0.52-source/splash/SplashT1Font.o +0 -0
- data/pdf2json-0.52-source/splash/SplashT1FontEngine.cc +124 -0
- data/pdf2json-0.52-source/splash/SplashT1FontEngine.h +53 -0
- data/pdf2json-0.52-source/splash/SplashT1FontEngine.o +0 -0
- data/pdf2json-0.52-source/splash/SplashT1FontFile.cc +97 -0
- data/pdf2json-0.52-source/splash/SplashT1FontFile.h +58 -0
- data/pdf2json-0.52-source/splash/SplashT1FontFile.o +0 -0
- data/pdf2json-0.52-source/splash/SplashTypes.h +132 -0
- data/pdf2json-0.52-source/splash/SplashXPath.cc +438 -0
- data/pdf2json-0.52-source/splash/SplashXPath.h +100 -0
- data/pdf2json-0.52-source/splash/SplashXPath.o +0 -0
- data/pdf2json-0.52-source/splash/SplashXPathScanner.cc +428 -0
- data/pdf2json-0.52-source/splash/SplashXPathScanner.h +87 -0
- data/pdf2json-0.52-source/splash/SplashXPathScanner.o +0 -0
- data/pdf2json-0.52-source/splash/libsplash.a +0 -0
- data/pdf2json-0.52-source/splash/vms_make.com +0 -0
- data/pdf2json-0.52-source/src/.DS_Store +0 -0
- data/pdf2json-0.52-source/src/GVector.h +101 -0
- data/pdf2json-0.52-source/src/ImgOutputDev.cc +1243 -0
- data/pdf2json-0.52-source/src/ImgOutputDev.h +307 -0
- data/pdf2json-0.52-source/src/ImgOutputDev.o +0 -0
- data/pdf2json-0.52-source/src/Makefile +68 -0
- data/pdf2json-0.52-source/src/Makefile.in +68 -0
- data/pdf2json-0.52-source/src/XmlFonts.cc +367 -0
- data/pdf2json-0.52-source/src/XmlFonts.h +91 -0
- data/pdf2json-0.52-source/src/XmlFonts.o +0 -0
- data/pdf2json-0.52-source/src/XmlLinks.cc +101 -0
- data/pdf2json-0.52-source/src/XmlLinks.h +54 -0
- data/pdf2json-0.52-source/src/XmlLinks.o +0 -0
- data/pdf2json-0.52-source/src/pdf2json +0 -0
- data/pdf2json-0.52-source/src/pdf2json.cc +343 -0
- data/pdf2json-0.52-source/src/pdf2json.o +0 -0
- data/pdf2json-0.52-source/src/pdf2xml.dtd +22 -0
- data/pdf2json-0.52-source/src/pdf2xmljson.dtd +9 -0
- data/pdf2json-0.52-source/xpdf/.DS_Store +0 -0
- data/pdf2json-0.52-source/xpdf/Annot.cc +1556 -0
- data/pdf2json-0.52-source/xpdf/Annot.h +142 -0
- data/pdf2json-0.52-source/xpdf/Annot.o +0 -0
- data/pdf2json-0.52-source/xpdf/Array.cc +73 -0
- data/pdf2json-0.52-source/xpdf/Array.h +58 -0
- data/pdf2json-0.52-source/xpdf/Array.o +0 -0
- data/pdf2json-0.52-source/xpdf/BuiltinFont.cc +65 -0
- data/pdf2json-0.52-source/xpdf/BuiltinFont.h +57 -0
- data/pdf2json-0.52-source/xpdf/BuiltinFont.o +0 -0
- data/pdf2json-0.52-source/xpdf/BuiltinFontTables.cc +4284 -0
- data/pdf2json-0.52-source/xpdf/BuiltinFontTables.h +23 -0
- data/pdf2json-0.52-source/xpdf/BuiltinFontTables.o +0 -0
- data/pdf2json-0.52-source/xpdf/CMap.cc +408 -0
- data/pdf2json-0.52-source/xpdf/CMap.h +102 -0
- data/pdf2json-0.52-source/xpdf/CMap.o +0 -0
- data/pdf2json-0.52-source/xpdf/Catalog.cc +374 -0
- data/pdf2json-0.52-source/xpdf/Catalog.h +97 -0
- data/pdf2json-0.52-source/xpdf/Catalog.o +0 -0
- data/pdf2json-0.52-source/xpdf/CharCodeToUnicode.cc +540 -0
- data/pdf2json-0.52-source/xpdf/CharCodeToUnicode.h +117 -0
- data/pdf2json-0.52-source/xpdf/CharCodeToUnicode.o +0 -0
- data/pdf2json-0.52-source/xpdf/CharTypes.h +24 -0
- data/pdf2json-0.52-source/xpdf/CompactFontTables.h +464 -0
- data/pdf2json-0.52-source/xpdf/CoreOutputDev.cc +61 -0
- data/pdf2json-0.52-source/xpdf/CoreOutputDev.h +61 -0
- data/pdf2json-0.52-source/xpdf/Decrypt.cc +776 -0
- data/pdf2json-0.52-source/xpdf/Decrypt.h +95 -0
- data/pdf2json-0.52-source/xpdf/Decrypt.o +0 -0
- data/pdf2json-0.52-source/xpdf/Dict.cc +95 -0
- data/pdf2json-0.52-source/xpdf/Dict.h +77 -0
- data/pdf2json-0.52-source/xpdf/Dict.o +0 -0
- data/pdf2json-0.52-source/xpdf/Error.cc +38 -0
- data/pdf2json-0.52-source/xpdf/Error.h +23 -0
- data/pdf2json-0.52-source/xpdf/Error.o +0 -0
- data/pdf2json-0.52-source/xpdf/ErrorCodes.h +36 -0
- data/pdf2json-0.52-source/xpdf/FontEncodingTables.cc +1824 -0
- data/pdf2json-0.52-source/xpdf/FontEncodingTables.h +20 -0
- data/pdf2json-0.52-source/xpdf/FontEncodingTables.o +0 -0
- data/pdf2json-0.52-source/xpdf/Function.cc +1573 -0
- data/pdf2json-0.52-source/xpdf/Function.h +229 -0
- data/pdf2json-0.52-source/xpdf/Function.o +0 -0
- data/pdf2json-0.52-source/xpdf/Gfx.cc +4187 -0
- data/pdf2json-0.52-source/xpdf/Gfx.h +312 -0
- data/pdf2json-0.52-source/xpdf/Gfx.o +0 -0
- data/pdf2json-0.52-source/xpdf/GfxFont.cc +1568 -0
- data/pdf2json-0.52-source/xpdf/GfxFont.h +320 -0
- data/pdf2json-0.52-source/xpdf/GfxFont.o +0 -0
- data/pdf2json-0.52-source/xpdf/GfxState.cc +4137 -0
- data/pdf2json-0.52-source/xpdf/GfxState.h +1244 -0
- data/pdf2json-0.52-source/xpdf/GfxState.o +0 -0
- data/pdf2json-0.52-source/xpdf/GlobalParams.cc +2924 -0
- data/pdf2json-0.52-source/xpdf/GlobalParams.cc.old +2908 -0
- data/pdf2json-0.52-source/xpdf/GlobalParams.h +466 -0
- data/pdf2json-0.52-source/xpdf/GlobalParams.h.old +463 -0
- data/pdf2json-0.52-source/xpdf/GlobalParams.o +0 -0
- data/pdf2json-0.52-source/xpdf/ImageOutputDev.cc +195 -0
- data/pdf2json-0.52-source/xpdf/ImageOutputDev.h +76 -0
- data/pdf2json-0.52-source/xpdf/ImageOutputDev.o +0 -0
- data/pdf2json-0.52-source/xpdf/JArithmeticDecoder.cc +322 -0
- data/pdf2json-0.52-source/xpdf/JArithmeticDecoder.h +109 -0
- data/pdf2json-0.52-source/xpdf/JArithmeticDecoder.o +0 -0
- data/pdf2json-0.52-source/xpdf/JBIG2Stream.cc +3413 -0
- data/pdf2json-0.52-source/xpdf/JBIG2Stream.h +145 -0
- data/pdf2json-0.52-source/xpdf/JBIG2Stream.o +0 -0
- data/pdf2json-0.52-source/xpdf/JPXStream.cc +3144 -0
- data/pdf2json-0.52-source/xpdf/JPXStream.h +351 -0
- data/pdf2json-0.52-source/xpdf/JPXStream.o +0 -0
- data/pdf2json-0.52-source/xpdf/Lexer.cc +485 -0
- data/pdf2json-0.52-source/xpdf/Lexer.h +80 -0
- data/pdf2json-0.52-source/xpdf/Lexer.o +0 -0
- data/pdf2json-0.52-source/xpdf/Link.cc +806 -0
- data/pdf2json-0.52-source/xpdf/Link.cc.old +784 -0
- data/pdf2json-0.52-source/xpdf/Link.h +415 -0
- data/pdf2json-0.52-source/xpdf/Link.h.old +369 -0
- data/pdf2json-0.52-source/xpdf/Link.o +0 -0
- data/pdf2json-0.52-source/xpdf/Makefile +232 -0
- data/pdf2json-0.52-source/xpdf/Makefile.dep +0 -0
- data/pdf2json-0.52-source/xpdf/Makefile.in +232 -0
- data/pdf2json-0.52-source/xpdf/NameToCharCode.cc +116 -0
- data/pdf2json-0.52-source/xpdf/NameToCharCode.h +42 -0
- data/pdf2json-0.52-source/xpdf/NameToCharCode.o +0 -0
- data/pdf2json-0.52-source/xpdf/NameToUnicodeTable.h +1097 -0
- data/pdf2json-0.52-source/xpdf/Object.cc +231 -0
- data/pdf2json-0.52-source/xpdf/Object.h +303 -0
- data/pdf2json-0.52-source/xpdf/Object.o +0 -0
- data/pdf2json-0.52-source/xpdf/Outline.cc +151 -0
- data/pdf2json-0.52-source/xpdf/Outline.h +76 -0
- data/pdf2json-0.52-source/xpdf/Outline.o +0 -0
- data/pdf2json-0.52-source/xpdf/OutputDev.cc +131 -0
- data/pdf2json-0.52-source/xpdf/OutputDev.h +253 -0
- data/pdf2json-0.52-source/xpdf/OutputDev.o +0 -0
- data/pdf2json-0.52-source/xpdf/PDFCore.cc +2044 -0
- data/pdf2json-0.52-source/xpdf/PDFCore.h +321 -0
- data/pdf2json-0.52-source/xpdf/PDFDoc.cc +404 -0
- data/pdf2json-0.52-source/xpdf/PDFDoc.h +183 -0
- data/pdf2json-0.52-source/xpdf/PDFDoc.o +0 -0
- data/pdf2json-0.52-source/xpdf/PDFDocEncoding.cc +44 -0
- data/pdf2json-0.52-source/xpdf/PDFDocEncoding.h +16 -0
- data/pdf2json-0.52-source/xpdf/PDFDocEncoding.o +0 -0
- data/pdf2json-0.52-source/xpdf/PSOutputDev.cc +6224 -0
- data/pdf2json-0.52-source/xpdf/PSOutputDev.h +395 -0
- data/pdf2json-0.52-source/xpdf/PSOutputDev.o +0 -0
- data/pdf2json-0.52-source/xpdf/PSTokenizer.cc +135 -0
- data/pdf2json-0.52-source/xpdf/PSTokenizer.h +41 -0
- data/pdf2json-0.52-source/xpdf/PSTokenizer.o +0 -0
- data/pdf2json-0.52-source/xpdf/Page.cc +454 -0
- data/pdf2json-0.52-source/xpdf/Page.h +187 -0
- data/pdf2json-0.52-source/xpdf/Page.o +0 -0
- data/pdf2json-0.52-source/xpdf/Parser.cc +227 -0
- data/pdf2json-0.52-source/xpdf/Parser.h +59 -0
- data/pdf2json-0.52-source/xpdf/Parser.o +0 -0
- data/pdf2json-0.52-source/xpdf/PreScanOutputDev.cc +257 -0
- data/pdf2json-0.52-source/xpdf/PreScanOutputDev.h +130 -0
- data/pdf2json-0.52-source/xpdf/PreScanOutputDev.o +0 -0
- data/pdf2json-0.52-source/xpdf/SecurityHandler.cc +390 -0
- data/pdf2json-0.52-source/xpdf/SecurityHandler.h +160 -0
- data/pdf2json-0.52-source/xpdf/SecurityHandler.o +0 -0
- data/pdf2json-0.52-source/xpdf/SplashOutputDev.cc +2845 -0
- data/pdf2json-0.52-source/xpdf/SplashOutputDev.h +247 -0
- data/pdf2json-0.52-source/xpdf/SplashOutputDev.o +0 -0
- data/pdf2json-0.52-source/xpdf/Stream-CCITT.h +459 -0
- data/pdf2json-0.52-source/xpdf/Stream.cc +4627 -0
- data/pdf2json-0.52-source/xpdf/Stream.h +858 -0
- data/pdf2json-0.52-source/xpdf/Stream.o +0 -0
- data/pdf2json-0.52-source/xpdf/TextOutputDev.cc +4090 -0
- data/pdf2json-0.52-source/xpdf/TextOutputDev.h +661 -0
- data/pdf2json-0.52-source/xpdf/TextOutputDev.o +0 -0
- data/pdf2json-0.52-source/xpdf/UTF8.h +56 -0
- data/pdf2json-0.52-source/xpdf/UnicodeMap.cc +302 -0
- data/pdf2json-0.52-source/xpdf/UnicodeMap.cc.old +293 -0
- data/pdf2json-0.52-source/xpdf/UnicodeMap.h +135 -0
- data/pdf2json-0.52-source/xpdf/UnicodeMap.h.old +123 -0
- data/pdf2json-0.52-source/xpdf/UnicodeMap.o +0 -0
- data/pdf2json-0.52-source/xpdf/UnicodeMapTables.h +361 -0
- data/pdf2json-0.52-source/xpdf/UnicodeTypeTable.cc +949 -0
- data/pdf2json-0.52-source/xpdf/UnicodeTypeTable.h +20 -0
- data/pdf2json-0.52-source/xpdf/UnicodeTypeTable.o +0 -0
- data/pdf2json-0.52-source/xpdf/XPDFApp.cc +447 -0
- data/pdf2json-0.52-source/xpdf/XPDFApp.h +114 -0
- data/pdf2json-0.52-source/xpdf/XPDFCore.cc +1655 -0
- data/pdf2json-0.52-source/xpdf/XPDFCore.h +251 -0
- data/pdf2json-0.52-source/xpdf/XPDFTree.cc +931 -0
- data/pdf2json-0.52-source/xpdf/XPDFTree.h +45 -0
- data/pdf2json-0.52-source/xpdf/XPDFTreeP.h +87 -0
- data/pdf2json-0.52-source/xpdf/XPDFViewer.cc +3488 -0
- data/pdf2json-0.52-source/xpdf/XPDFViewer.h +352 -0
- data/pdf2json-0.52-source/xpdf/XRef.cc +896 -0
- data/pdf2json-0.52-source/xpdf/XRef.h +133 -0
- data/pdf2json-0.52-source/xpdf/XRef.o +0 -0
- data/pdf2json-0.52-source/xpdf/XpdfPluginAPI.cc +262 -0
- data/pdf2json-0.52-source/xpdf/XpdfPluginAPI.h +341 -0
- data/pdf2json-0.52-source/xpdf/XpdfPluginAPI.o +0 -0
- data/pdf2json-0.52-source/xpdf/about-text.h +48 -0
- data/pdf2json-0.52-source/xpdf/about.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/backArrow.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/backArrowDis.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/config.h +112 -0
- data/pdf2json-0.52-source/xpdf/dblLeftArrow.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/dblLeftArrowDis.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/dblRightArrow.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/dblRightArrowDis.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/find.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/findDis.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/forwardArrow.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/forwardArrowDis.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/leftArrow.xbm +5 -0
- data/pdf2json-0.52-source/xpdf/leftArrowDis.xbm +5 -0
- data/pdf2json-0.52-source/xpdf/libXpdf.a +0 -0
- data/pdf2json-0.52-source/xpdf/pdffonts +0 -0
- data/pdf2json-0.52-source/xpdf/pdffonts.cc +298 -0
- data/pdf2json-0.52-source/xpdf/pdffonts.o +0 -0
- data/pdf2json-0.52-source/xpdf/pdfimages +0 -0
- data/pdf2json-0.52-source/xpdf/pdfimages.cc +155 -0
- data/pdf2json-0.52-source/xpdf/pdfimages.o +0 -0
- data/pdf2json-0.52-source/xpdf/pdfinfo +0 -0
- data/pdf2json-0.52-source/xpdf/pdfinfo.cc +387 -0
- data/pdf2json-0.52-source/xpdf/pdfinfo.o +0 -0
- data/pdf2json-0.52-source/xpdf/pdftoppm.cc +203 -0
- data/pdf2json-0.52-source/xpdf/pdftops +0 -0
- data/pdf2json-0.52-source/xpdf/pdftops.cc +344 -0
- data/pdf2json-0.52-source/xpdf/pdftops.o +0 -0
- data/pdf2json-0.52-source/xpdf/pdftotext +0 -0
- data/pdf2json-0.52-source/xpdf/pdftotext.cc +333 -0
- data/pdf2json-0.52-source/xpdf/pdftotext.o +0 -0
- data/pdf2json-0.52-source/xpdf/print.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/printDis.xbm +6 -0
- data/pdf2json-0.52-source/xpdf/rightArrow.xbm +5 -0
- data/pdf2json-0.52-source/xpdf/rightArrowDis.xbm +5 -0
- data/pdf2json-0.52-source/xpdf/vms_make.com +129 -0
- data/pdf2json-0.52-source/xpdf/xpdf.cc +344 -0
- data/pdf2json-0.52-source/xpdf/xpdfIcon.xpm +62 -0
- data/pdf2json.gemspec +29 -0
- metadata +518 -0
Binary file
|
@@ -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
|
+
|
35
|
+
PDFCorePage::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
|
+
|
46
|
+
PDFCorePage::~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
|
+
|
60
|
+
PDFCoreTile::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
|
+
|
70
|
+
PDFCoreTile::~PDFCoreTile() {
|
71
|
+
if (bitmap) {
|
72
|
+
delete bitmap;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
|
77
|
+
//------------------------------------------------------------------------
|
78
|
+
// PDFCore
|
79
|
+
//------------------------------------------------------------------------
|
80
|
+
|
81
|
+
PDFCore::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
|
+
|
120
|
+
PDFCore::~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
|
+
|
136
|
+
int 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
|
148
|
+
int 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
|
+
|
160
|
+
int 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
|
+
|
170
|
+
void PDFCore::loadDoc(PDFDoc *docA) {
|
171
|
+
setBusyCursor(gTrue);
|
172
|
+
loadFile2(docA);
|
173
|
+
setBusyCursor(gFalse);
|
174
|
+
}
|
175
|
+
|
176
|
+
int 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
|
+
|
222
|
+
void 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
|
+
|
244
|
+
PDFDoc *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
|
+
|
272
|
+
void 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
|
+
|
295
|
+
void 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
|
+
|
369
|
+
void 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
|
+
|
725
|
+
void 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
|
+
|
755
|
+
void 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
|
+
|
857
|
+
GBool 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
|
+
|
877
|
+
GBool 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
|
+
|
902
|
+
GBool 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
|
+
|
916
|
+
GBool 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
|
+
|
938
|
+
GBool 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
|
+
|
960
|
+
void PDFCore::scrollLeft(int nCols) {
|
961
|
+
scrollTo(scrollX - nCols, scrollY);
|
962
|
+
}
|
963
|
+
|
964
|
+
void PDFCore::scrollRight(int nCols) {
|
965
|
+
scrollTo(scrollX + nCols, scrollY);
|
966
|
+
}
|
967
|
+
|
968
|
+
void PDFCore::scrollUp(int nLines) {
|
969
|
+
scrollTo(scrollX, scrollY - nLines);
|
970
|
+
}
|
971
|
+
|
972
|
+
void PDFCore::scrollUpPrevPage(int nLines) {
|
973
|
+
if (!continuousMode && scrollY == 0) {
|
974
|
+
gotoPrevPage(1, gFalse, gTrue);
|
975
|
+
} else {
|
976
|
+
scrollTo(scrollX, scrollY - nLines);
|
977
|
+
}
|
978
|
+
}
|
979
|
+
|
980
|
+
void PDFCore::scrollDown(int nLines) {
|
981
|
+
scrollTo(scrollX, scrollY + nLines);
|
982
|
+
}
|
983
|
+
|
984
|
+
void 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
|
+
|
993
|
+
void PDFCore::scrollPageUp() {
|
994
|
+
if (!continuousMode && scrollY == 0) {
|
995
|
+
gotoPrevPage(1, gFalse, gTrue);
|
996
|
+
} else {
|
997
|
+
scrollTo(scrollX, scrollY - drawAreaHeight);
|
998
|
+
}
|
999
|
+
}
|
1000
|
+
|
1001
|
+
void 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
|
+
|
1010
|
+
void PDFCore::scrollTo(int x, int y) {
|
1011
|
+
update(topPage, x, y < 0 ? 0 : y, zoom, rotate, gFalse, gFalse);
|
1012
|
+
}
|
1013
|
+
|
1014
|
+
void PDFCore::scrollToLeftEdge() {
|
1015
|
+
update(topPage, 0, scrollY, zoom, rotate, gFalse, gFalse);
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
void 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
|
+
|
1026
|
+
void PDFCore::scrollToTopEdge() {
|
1027
|
+
int y;
|
1028
|
+
|
1029
|
+
y = continuousMode ? pageY[topPage - 1] : 0;
|
1030
|
+
update(topPage, scrollX, y, zoom, rotate, gFalse, gFalse);
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
void 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
|
+
|
1052
|
+
void PDFCore::scrollToTopLeft() {
|
1053
|
+
int y;
|
1054
|
+
|
1055
|
+
y = continuousMode ? pageY[topPage - 1] : 0;
|
1056
|
+
update(topPage, 0, y, zoom, rotate, gFalse, gFalse);
|
1057
|
+
}
|
1058
|
+
|
1059
|
+
void 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
|
+
|
1079
|
+
void 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
|
+
|
1123
|
+
void 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.
|
1212
|
+
void 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
|
+
|
1290
|
+
void PDFCore::setContinuousMode(GBool cm) {
|
1291
|
+
if (continuousMode != cm) {
|
1292
|
+
continuousMode = cm;
|
1293
|
+
update(topPage, scrollX, -1, zoom, rotate, gTrue, gFalse);
|
1294
|
+
}
|
1295
|
+
}
|
1296
|
+
|
1297
|
+
void 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
|
+
|
1441
|
+
void 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
|
+
|
1494
|
+
void 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
|
+
|
1548
|
+
GBool 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
|
+
|
1559
|
+
GString *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
|
+
|
1600
|
+
GBool 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
|
+
|
1619
|
+
GBool 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
|
+
|
1745
|
+
GBool 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
|
+
|
1769
|
+
GBool 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
|
+
|
1788
|
+
void 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
|
+
|
1811
|
+
void 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
|
+
|
1837
|
+
void 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
|
+
|
1849
|
+
void 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
|
+
|
1872
|
+
void PDFCore::setReverseVideo(GBool reverseVideoA) {
|
1873
|
+
out->setReverseVideo(reverseVideoA);
|
1874
|
+
update(topPage, scrollX, scrollY, zoom, rotate, gTrue, gFalse);
|
1875
|
+
}
|
1876
|
+
|
1877
|
+
LinkAction *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
|
+
|
1886
|
+
PDFCorePage *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
|
+
|
1899
|
+
void 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
|
+
|
1927
|
+
void 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
|
+
|
2010
|
+
PDFCoreTile *PDFCore::newTile(int xDestA, int yDestA) {
|
2011
|
+
return new PDFCoreTile(xDestA, yDestA);
|
2012
|
+
}
|
2013
|
+
|
2014
|
+
void PDFCore::updateTileData(PDFCoreTile *tileA, int xSrc, int ySrc,
|
2015
|
+
int width, int height, GBool composited) {
|
2016
|
+
}
|
2017
|
+
|
2018
|
+
void 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
|
+
}
|