summarylogtreecommitdiffstats
path: root/pdf-import.patch
blob: 05d8ffe888ea0f59ceea261543bee7194ed6be71 (plain)
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
--- plug-ins/pdf/pdf-import.cpp 2022-05-25 17:35:28.000000000 +0200
+++ plug-ins/pdf/pdf-import.cpp 2022-09-27 20:25:47.183817900 +0200
@@ -152,13 +152,12 @@ public :
   void
   updateLineDash (GfxState *state)
   {
-    double *dashPattern;
-    int dashLength;
-    double dashStart;
-
-    state->getLineDash (&dashPattern, &dashLength, &dashStart);
-    this->dash_length = dashLength ? dashPattern[0] * scale : 1.0;
-
+    const double *dashPattern=NULL;
+    int dashLength=0;
+    double dashStart=0;
+    const std::vector<double> &dash = state->getLineDash(&dashStart);  // > Poppler 22.09 ...
+    dashPattern = dash.data();
+    dashLength = dash.size();
     if (dashLength == 0)
       this->line_style = DIA_LINE_STYLE_SOLID;
     else if (dashLength > 5)
@@ -318,10 +317,10 @@ public :
     //FIXME: Dia is really unhappy about zero size fonts
     if (!(state->getFontSize() > 0.0))
       return;
-    GfxFont *f = state->getFont();
-
+   const std::shared_ptr<GfxFont> f = state->getFont();  // poppler 22.05 ... header changed
+   gconstpointer f1 = &f;  // GLib typedef const void * gconstpointer;
     // instead of building the same font over and over again
-    if (g_hash_table_lookup (this->font_map, f)) {
+    if (g_hash_table_lookup (this->font_map, f1)) {
       ++font_map_hits;
       return;
     }
@@ -333,8 +332,9 @@ public :
     gchar *family = g_strdup (f->getFamily() ? f->getFamily()->c_str() : "sans");
 
     // we are (not anymore) building the same font over and over again
+    f1  = &f;
     g_print ("Font 0x%x: '%s' size=%g (* %g)\n",
-	     GPOINTER_TO_INT (f), family, state->getTransformedFontSize(), scale);
+	     GPOINTER_TO_INT (f1), family, state->getTransformedFontSize(), scale);
 
     // now try to make a fontname Dia/Pango can cope with
     // strip style postfix - we already have extracted the style bits above
@@ -353,8 +353,9 @@ public :
     if (fm[0] != 0)
       fsize *= fabs(fm[3] / fm[0]);
     font = dia_font_new (family, style, fsize * scale / 0.8);
-
-    g_hash_table_insert (this->font_map, f, font);
+   f1  = &f;
+   gpointer f2 = (gpointer)f1;  // GLib typedef void* gpointer;
+    g_hash_table_insert (this->font_map, f2, font);
     g_free (family);
   }
   void updateTextShift(GfxState *state, double shift)
@@ -721,11 +722,15 @@ DiaOutputDev::drawString(GfxState *state
     return;
   if (!(state->getFontSize() > 0.0))
     return;
-  font = (DiaFont *)g_hash_table_lookup (this->font_map, state->getFont());
+gconstpointer f_1 = &state->getFont();
+// g_print ("f_1 %p\n", f_1);
+font = (DiaFont *)g_hash_table_lookup (this->font_map, f_1);
+//  font = (DiaFont *)g_hash_table_lookup (this->font_map, &(state->getFont()));
 
   // we have to decode the string data first
   {
-    GfxFont *f = state->getFont();
+//    GfxFont *f = state->getFont();
+   const std::shared_ptr<GfxFont> f = state->getFont();
     const char *p = s->c_str();
     CharCode code;
     int   j = 0, m, n;
@@ -870,8 +875,10 @@ import_pdf(const gchar *filename, Diagra
   std::unique_ptr<PDFDoc> doc;
   GooString *fileName = new GooString(filename);
   // no passwords yet
-  GooString *ownerPW = NULL;
-  GooString *userPW = NULL;
+  //GooString *ownerPW = NULL;
+  //GooString *userPW = NULL;
+  const std::optional<GooString> ownerPW;
+  const std::optional<GooString> userPW;
   gboolean ret = FALSE;
 
   // without this we will get strange crashes (at least with /O2 build)
@@ -899,7 +906,8 @@ import_pdf(const gchar *filename, Diagra
     delete diaOut;
     ret = TRUE;
   }
-  delete fileName;
+ doc.reset();
+ delete fileName;
 
   return ret;
 }