gdal/gdal-svn28438-poppler31.diff

119 lines
5.0 KiB
Diff
Raw Normal View History

2015-06-09 20:07:19 +00:00
diff -up gdal-1.11.2-fedora/frmts/pdf/pdfdataset.cpp.poppler31~ gdal-1.11.2-fedora/frmts/pdf/pdfdataset.cpp
--- gdal-1.11.2-fedora/frmts/pdf/pdfdataset.cpp.poppler31~ 2015-02-10 13:11:19.000000000 +0100
+++ gdal-1.11.2-fedora/frmts/pdf/pdfdataset.cpp 2015-06-09 21:39:32.000000000 +0200
@@ -108,12 +108,9 @@ class GDALPDFOutputDev : public SplashOu
public:
GDALPDFOutputDev(SplashColorMode colorModeA, int bitmapRowPadA,
- GBool reverseVideoA, SplashColorPtr paperColorA,
- GBool bitmapTopDownA = gTrue,
- GBool allowAntialiasA = gTrue) :
+ GBool reverseVideoA, SplashColorPtr paperColorA) :
SplashOutputDev(colorModeA, bitmapRowPadA,
- reverseVideoA, paperColorA,
- bitmapTopDownA, allowAntialiasA),
+ reverseVideoA, paperColorA),
bEnableVector(TRUE),
bEnableText(TRUE),
bEnableBitmap(TRUE) {}
diff -up gdal-1.11.2-fedora/frmts/pdf/pdfio.cpp.poppler31~ gdal-1.11.2-fedora/frmts/pdf/pdfio.cpp
--- gdal-1.11.2-fedora/frmts/pdf/pdfio.cpp.poppler31~ 2015-02-10 13:11:19.000000000 +0100
+++ gdal-1.11.2-fedora/frmts/pdf/pdfio.cpp 2015-06-09 21:41:18.000000000 +0200
@@ -39,13 +39,24 @@
CPL_CVSID("$Id: pdfio.cpp 27044 2014-03-16 23:41:27Z rouault $");
+#ifdef POPPLER_BASE_STREAM_HAS_TWO_ARGS
+/* Poppler 0.31.0 is the first one that needs to know the file size */
+static vsi_l_offset VSIPDFFileStreamGetSize(VSILFILE* f)
+{
+ VSIFSeekL(f, 0, SEEK_END);
+ vsi_l_offset nSize = VSIFTellL(f);
+ VSIFSeekL(f, 0, SEEK_SET);
+ return nSize;
+}
+#endif
+
/************************************************************************/
/* VSIPDFFileStream() */
/************************************************************************/
VSIPDFFileStream::VSIPDFFileStream(VSILFILE* f, const char* pszFilename, Object *dictA):
#ifdef POPPLER_BASE_STREAM_HAS_TWO_ARGS
- BaseStream(dictA, 0)
+ BaseStream(dictA, (setPos_offset_type)VSIPDFFileStreamGetSize(f))
#else
BaseStream(dictA)
#endif
@@ -195,7 +206,7 @@ int VSIPDFFileStream::FillBuffer()
/* getChar() */
/************************************************************************/
-/* The unoptimized version performs a bit well since we must go through */
+/* The unoptimized version performs a bit less since we must go through */
/* the whole virtual I/O chain for each character reading. We save a few */
/* percent with this extra internal caching */
@@ -326,4 +337,47 @@ void VSIPDFFileStream::moveStart(moveSta
nPosInBuffer = nBufferLength = -1;
}
+/************************************************************************/
+/* hasGetChars() */
+/************************************************************************/
+
+GBool VSIPDFFileStream::hasGetChars()
+{
+ return true;
+}
+
+/************************************************************************/
+/* getChars() */
+/************************************************************************/
+
+int VSIPDFFileStream::getChars(int nChars, Guchar *buffer)
+{
+ int nRead = 0;
+ while (nRead < nChars)
+ {
+ int nToRead = nChars - nRead;
+ if (nPosInBuffer == nBufferLength)
+ {
+ if (!bLimited && nToRead > BUFFER_SIZE)
+ {
+ int nJustRead = (int) VSIFReadL(buffer + nRead, 1, nToRead, f);
+ nPosInBuffer = nBufferLength = -1;
+ nCurrentPos += nJustRead;
+ nRead += nJustRead;
+ break;
+ }
+ else if (!FillBuffer() || nPosInBuffer >= nBufferLength)
+ break;
+ }
+ if( nToRead > nBufferLength - nPosInBuffer )
+ nToRead = nBufferLength - nPosInBuffer;
+
+ memcpy( buffer + nRead, abyBuffer + nPosInBuffer, nToRead );
+ nPosInBuffer += nToRead;
+ nCurrentPos += nToRead;
+ nRead += nToRead;
+ }
+ return nRead;
+}
+
#endif
diff -up gdal-1.11.2-fedora/frmts/pdf/pdfio.h.poppler31~ gdal-1.11.2-fedora/frmts/pdf/pdfio.h
--- gdal-1.11.2-fedora/frmts/pdf/pdfio.h.poppler31~ 2015-02-10 13:11:19.000000000 +0100
+++ gdal-1.11.2-fedora/frmts/pdf/pdfio.h 2015-06-09 21:39:48.000000000 +0200
@@ -93,6 +93,10 @@ class VSIPDFFileStream: public BaseStrea
virtual void close();
private:
+ /* Added in poppler 0.15.0 */
+ virtual GBool hasGetChars();
+ virtual int getChars(int nChars, Guchar *buffer);
+
VSIPDFFileStream *poParent;
GooString *poFilename;
VSILFILE *f;