Added
Link Here
|
1 |
--- frmts/pdf/pdfobject.cpp.orig 2019-05-08 16:11:48 UTC |
2 |
+++ frmts/pdf/pdfobject.cpp |
3 |
@@ -38,7 +38,7 @@ |
4 |
#include <vector> |
5 |
#include "pdfobject.h" |
6 |
|
7 |
-CPL_CVSID("$Id: pdfobject.cpp d295d0ebc3b41092ad072790c704c772098da210 2019-01-17 22:52:36 +0100 Even Rouault $") |
8 |
+CPL_CVSID("$Id$") |
9 |
|
10 |
/************************************************************************/ |
11 |
/* ROUND_TO_INT_IF_CLOSE() */ |
12 |
@@ -1195,7 +1195,7 @@ GDALPDFObject* GDALPDFDictionaryPoppler::Get(const cha |
13 |
return oIter->second; |
14 |
|
15 |
#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58 |
16 |
- Object o = m_poDict->lookupNF(((char*)pszKey)); |
17 |
+ auto&& o(m_poDict->lookupNF(((char*)pszKey))); |
18 |
if (!o.isNull()) |
19 |
{ |
20 |
int nRefNum = 0; |
21 |
@@ -1204,7 +1204,7 @@ GDALPDFObject* GDALPDFDictionaryPoppler::Get(const cha |
22 |
{ |
23 |
nRefNum = o.getRefNum(); |
24 |
nRefGen = o.getRefGen(); |
25 |
- Object o2 = m_poDict->lookup((char*)pszKey); |
26 |
+ Object o2(m_poDict->lookup((char*)pszKey)); |
27 |
if( !o2.isNull() ) |
28 |
{ |
29 |
GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o2)), TRUE); |
30 |
@@ -1215,7 +1215,7 @@ GDALPDFObject* GDALPDFDictionaryPoppler::Get(const cha |
31 |
} |
32 |
else |
33 |
{ |
34 |
- GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o)), TRUE); |
35 |
+ GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o.copy())), TRUE); |
36 |
poObj->SetRefNumAndGen(nRefNum, nRefGen); |
37 |
m_map[pszKey] = poObj; |
38 |
return poObj; |
39 |
@@ -1329,7 +1329,7 @@ GDALPDFObject* GDALPDFArrayPoppler::Get(int nIndex) |
40 |
return m_v[nIndex]; |
41 |
|
42 |
#if POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 58 |
43 |
- Object o = m_poArray->getNF(nIndex); |
44 |
+ auto&& o(m_poArray->getNF(nIndex)); |
45 |
if( !o.isNull() ) |
46 |
{ |
47 |
int nRefNum = 0; |
48 |
@@ -1338,7 +1338,7 @@ GDALPDFObject* GDALPDFArrayPoppler::Get(int nIndex) |
49 |
{ |
50 |
nRefNum = o.getRefNum(); |
51 |
nRefGen = o.getRefGen(); |
52 |
- Object o2 = m_poArray->get(nIndex); |
53 |
+ Object o2(m_poArray->get(nIndex)); |
54 |
if( !o2.isNull() ) |
55 |
{ |
56 |
GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o2)), TRUE); |
57 |
@@ -1349,7 +1349,7 @@ GDALPDFObject* GDALPDFArrayPoppler::Get(int nIndex) |
58 |
} |
59 |
else |
60 |
{ |
61 |
- GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o)), TRUE); |
62 |
+ GDALPDFObjectPoppler* poObj = new GDALPDFObjectPoppler(new Object(std::move(o.copy())), TRUE); |
63 |
poObj->SetRefNumAndGen(nRefNum, nRefGen); |
64 |
m_v[nIndex] = poObj; |
65 |
return poObj; |
66 |
@@ -1416,8 +1416,6 @@ int GDALPDFStreamPoppler::GetLength() |
67 |
|
68 |
char* GDALPDFStreamPoppler::GetBytes() |
69 |
{ |
70 |
- /* fillGooString() available in poppler >= 0.16.0 */ |
71 |
-#ifdef POPPLER_BASE_STREAM_HAS_TWO_ARGS |
72 |
GooString* gstr = new GooString(); |
73 |
m_poStream->fillGooString(gstr); |
74 |
|
75 |
@@ -1427,7 +1425,12 @@ char* GDALPDFStreamPoppler::GetBytes() |
76 |
char* pszContent = (char*) VSIMalloc(m_nLength + 1); |
77 |
if (pszContent) |
78 |
{ |
79 |
- memcpy(pszContent, gstr->getCString(), m_nLength); |
80 |
+#if (POPPLER_MAJOR_VERSION >= 1 || POPPLER_MINOR_VERSION >= 72) |
81 |
+ const char* srcStr = gstr->c_str(); |
82 |
+#else |
83 |
+ const char* srcStr = gstr->getCString(); |
84 |
+#endif |
85 |
+ memcpy(pszContent, srcStr, m_nLength); |
86 |
pszContent[m_nLength] = '\0'; |
87 |
} |
88 |
delete gstr; |
89 |
@@ -1438,41 +1441,6 @@ char* GDALPDFStreamPoppler::GetBytes() |
90 |
delete gstr; |
91 |
return nullptr; |
92 |
} |
93 |
-#else |
94 |
- int i; |
95 |
- int nLengthAlloc = 0; |
96 |
- char* pszContent = nullptr; |
97 |
- if( m_nLength >= 0 ) |
98 |
- { |
99 |
- pszContent = (char*) VSIMalloc(m_nLength + 1); |
100 |
- if (!pszContent) |
101 |
- return nullptr; |
102 |
- nLengthAlloc = m_nLength; |
103 |
- } |
104 |
- m_poStream->reset(); |
105 |
- for(i = 0; ; ++i ) |
106 |
- { |
107 |
- int nVal = m_poStream->getChar(); |
108 |
- if (nVal == EOF) |
109 |
- break; |
110 |
- if( i >= nLengthAlloc ) |
111 |
- { |
112 |
- nLengthAlloc = 32 + nLengthAlloc + nLengthAlloc / 3; |
113 |
- char* pszContentNew = (char*) VSIRealloc(pszContent, nLengthAlloc + 1); |
114 |
- if( pszContentNew == nullptr ) |
115 |
- { |
116 |
- CPLFree(pszContent); |
117 |
- m_nLength = 0; |
118 |
- return nullptr; |
119 |
- } |
120 |
- pszContent = pszContentNew; |
121 |
- } |
122 |
- pszContent[i] = (GByte)nVal; |
123 |
- } |
124 |
- m_nLength = i; |
125 |
- pszContent[i] = '\0'; |
126 |
- return pszContent; |
127 |
-#endif |
128 |
} |
129 |
|
130 |
#endif // HAVE_POPPLER |