Package: gambas3 / 3.13.0-1

0f044b9512d29916bcd83e89fb07de6fa5b9ea61.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
From 0f044b9512d29916bcd83e89fb07de6fa5b9ea61 Mon Sep 17 00:00:00 2001
From: gambas <g4mba5@gmail.com>
Date: Wed, 1 May 2019 14:39:44 +0200
Subject: [PATCH] Try again to compile with poppler 0.76.

[GB.PDF]
* BUG: Try again to compile with poppler 0.76.
---
 gb.pdf/src/CPdfDocument.cpp | 39 +++++++++++++++++++------------------
 gb.pdf/src/CPdfDocument.h   | 22 ++++++++++++++++++++-
 2 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/gb.pdf/src/CPdfDocument.cpp b/gb.pdf/src/CPdfDocument.cpp
index f52d9c2a0..03b94ac46 100644
--- a/gb.pdf/src/CPdfDocument.cpp
+++ b/gb.pdf/src/CPdfDocument.cpp
@@ -717,7 +717,7 @@ PDF document index
 
 BEGIN_PROPERTY(PDFDOCUMENT_has_index)
 
-	GB.ReturnBoolean(THIS->index && THIS->index->getLength());
+	GB.ReturnBoolean(THIS->index && CPDF_index_count());
 
 END_PROPERTY
 
@@ -725,45 +725,45 @@ BEGIN_PROPERTY(PDFDOCUMENT_index)
 
 	if (!THIS->index) { GB.ReturnNull(); return; }
 	
-	THIS->action=((OutlineItem*)THIS->index->get(THIS->currindex))->getAction();
+	THIS->action=(CPDF_index_get(THIS->currindex))->getAction();
 	RETURN_SELF();
 
 END_PROPERTY
 
 BEGIN_PROPERTY(PDFINDEX_count)
 
-	GB.ReturnInteger(THIS->index->getLength());
+	GB.ReturnInteger(CPDF_index_count());
 
 END_PROPERTY
 
 BEGIN_PROPERTY(PDFINDEX_has_children)
 
-	OutlineItem *item;
+	OutlineItem *item = CPDF_index_get(THIS->currindex);
 
-	item = (OutlineItem *)THIS->index->get (THIS->currindex);
 	GB.ReturnBoolean(item->getKids() && item->getKids()->getLength());
 
 END_PROPERTY
 
 BEGIN_PROPERTY(PDFINDEX_is_open)
 
-	OutlineItem *item;
-
-	item = (OutlineItem *)THIS->index->get (THIS->currindex);
+	OutlineItem *item = CPDF_index_get(THIS->currindex);
 
 	if (READ_PROPERTY)
-	{	GB.ReturnBoolean(item->isOpen()); return; }
+	{
+		GB.ReturnBoolean(item->isOpen()); 
+		return;
+	}
 
-	if (VPROP(GB_INTEGER)) item->open();
-	else item->close();
+	if (VPROP(GB_INTEGER))
+		item->open();
+	else
+		item->close();
 
 END_PROPERTY
 
 BEGIN_PROPERTY(PDFINDEX_title)
 
-	OutlineItem *item;
-
-	item = (OutlineItem *)THIS->index->get (THIS->currindex);
+	OutlineItem *item = CPDF_index_get(THIS->currindex);
 	return_unicode_string(item->getTitle(), item->getTitleLength());
 
 END_PROPERTY
@@ -792,8 +792,11 @@ END_METHOD
 
 BEGIN_METHOD_VOID(PDFINDEX_next)
 
-	if ( (THIS->currindex+1) >= (uint32_t)THIS->index->getLength() )
-		 { GB.ReturnBoolean(true); return; }
+	if ((THIS->currindex + 1) >= (uint)CPDF_index_count())
+	{
+		GB.ReturnBoolean(true); 
+		return;
+	}
 
 	THIS->currindex++;
 	GB.ReturnBoolean(false);
@@ -802,9 +805,7 @@ END_METHOD
 
 BEGIN_METHOD_VOID(PDFINDEX_child)
 
-	OutlineItem *item;
-
-	item = (OutlineItem *)THIS->index->get (THIS->currindex);
+	OutlineItem *item = CPDF_index_get(THIS->currindex);
 
 	if (!item->hasKids() || item->getKids()->getLength() == 0) { GB.ReturnBoolean(true); return; }
 
diff --git a/gb.pdf/src/CPdfDocument.h b/gb.pdf/src/CPdfDocument.h
index 6aa73343b..cd794011e 100644
--- a/gb.pdf/src/CPdfDocument.h
+++ b/gb.pdf/src/CPdfDocument.h
@@ -31,12 +31,19 @@
 #include <Page.h>
 #if POPPLER_VERSION_0_76
 #include <vector>
+#include <Outline.h>
 #else
 #include <goo/GooList.h>
 #endif
 #include <stdint.h>
 
-#if POPPLER_VERSION_0_64
+#if POPPLER_VERSION_0_76
+#define const_LinkAction const LinkAction
+#define const_LinkDest const LinkDest
+#define const_GooList std::vector<OutlineItem*>
+#define GooList std::vector<OutlineItem*>
+#define const_GooString const GooString
+#elif POPPLER_VERSION_0_64
 #define const_LinkAction const LinkAction
 #define const_LinkDest const LinkDest
 #define const_GooList const GooList
@@ -68,6 +75,19 @@ extern GB_DESC PdfModeDesc[];
 
 #endif
 
+#if POPPLER_VERSION_0_76
+
+#define CPDF_index_get(_i) (THIS->index->at(_i))
+#define CPDF_index_count() (THIS->index->size())
+
+#else
+
+#define CPDF_index_get(_i) ((OutlineItem *)(THIS->index->get(_i)))
+#define CPDF_index_count() (THIS->index->getLength())
+
+#endif
+
+
 typedef
 	struct {
 		GB_BASE ob;
-- 
2.21.0