poppler 1.0.3 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1,26 @@
1
1
  /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
- /**********************************************************************
3
-
4
- rbpoppler-action.c -
5
-
6
- Copyright (C) 2006-2008 Ruby-GNOME2 Project Team
7
-
8
- **********************************************************************/
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2006-2008 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
9
21
 
10
22
  #include "rbpoppler-private.h"
11
23
 
12
- #define RVAL2DEST(obj) ((PopplerDest *)RVAL2BOXED(obj, POPPLER_TYPE_DEST))
13
- #define DEST2RVAL(obj) (BOXED2RVAL(obj, POPPLER_TYPE_DEST))
14
-
15
- #define DEST_TYPE2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_DEST_TYPE))
16
- #define ACTION_TYPE2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_ACTION_TYPE))
17
- #define RVAL2ACTION_TYPE(obj) (RVAL2GENUM(obj, POPPLER_TYPE_ACTION_TYPE))
18
-
19
-
20
24
  /* PopplerAction */
21
25
  static VALUE actions[POPPLER_ACTION_MOVIE + 1];
22
26
 
@@ -43,14 +47,14 @@ rb_poppler_action_from_ruby_object(VALUE action)
43
47
  static VALUE \
44
48
  action_ ## type ## _ ## name (VALUE self) \
45
49
  { \
46
- return CSTR2RVAL(RVAL2POPPLER_ACTION(self)->type.name); \
50
+ return CSTR2RVAL(RVAL2POPPLERACTION(self)->type.name); \
47
51
  }
48
52
 
49
53
  #define ACTION_ATTR_DEST(type, name) \
50
54
  static VALUE \
51
55
  action_ ## type ## _ ## name (VALUE self) \
52
56
  { \
53
- return DEST2RVAL(RVAL2POPPLER_ACTION(self)->type.name); \
57
+ return POPPLERDEST2RVAL(RVAL2POPPLERACTION(self)->type.name); \
54
58
  }
55
59
 
56
60
  #define DEFINE_ACCESSOR(prefix, target, name) \
@@ -63,7 +67,7 @@ action_ ## type ## _ ## name (VALUE self) \
63
67
  static VALUE
64
68
  action_any_type(VALUE self)
65
69
  {
66
- return ACTION_TYPE2RVAL(RVAL2POPPLER_ACTION(self)->type);
70
+ return POPPLERACTIONTYPE2RVAL(RVAL2POPPLERACTION(self)->type);
67
71
  }
68
72
  ACTION_ATTR_STR(any, title);
69
73
 
@@ -106,35 +110,35 @@ poppler_dest_get_type (void)
106
110
  static VALUE
107
111
  dest_get_type(VALUE self)
108
112
  {
109
- return DEST_TYPE2RVAL(RVAL2DEST(self)->type);
113
+ return POPPLERDESTTYPE2RVAL(RVAL2POPPLERDEST(self)->type);
110
114
  }
111
115
 
112
116
  #define DEST_ATTR_INT(name) \
113
117
  static VALUE \
114
118
  dest_ ## name (VALUE self) \
115
119
  { \
116
- return INT2NUM(RVAL2DEST(self)->name); \
120
+ return INT2NUM(RVAL2POPPLERDEST(self)->name); \
117
121
  }
118
122
 
119
123
  #define DEST_ATTR_UINT(name) \
120
124
  static VALUE \
121
125
  dest_ ## name (VALUE self) \
122
126
  { \
123
- return UINT2NUM(RVAL2DEST(self)->name); \
127
+ return UINT2NUM(RVAL2POPPLERDEST(self)->name); \
124
128
  }
125
129
 
126
130
  #define DEST_ATTR_DOUBLE(name) \
127
131
  static VALUE \
128
132
  dest_ ## name (VALUE self) \
129
133
  { \
130
- return rb_float_new(RVAL2DEST(self)->name); \
134
+ return rb_float_new(RVAL2POPPLERDEST(self)->name); \
131
135
  }
132
136
 
133
137
  #define DEST_ATTR_STR(name) \
134
138
  static VALUE \
135
139
  dest_ ## name (VALUE self) \
136
140
  { \
137
- return CSTR2RVAL(RVAL2DEST(self)->name); \
141
+ return CSTR2RVAL(RVAL2POPPLERDEST(self)->name); \
138
142
  }
139
143
 
140
144
  #define DEFINE_DEST_ACCESSOR(target, name) \
@@ -1,307 +1,74 @@
1
- /* -*- c-file-style: "ruby" -*- */
2
- /**********************************************************************
3
-
4
- rbpoppler-annotation.c -
5
-
6
- Copyright (C) 2008 Ruby-GNOME2 Project Team
7
-
8
- **********************************************************************/
1
+ /* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
2
+ /*
3
+ * Copyright (C) 2011 Ruby-GNOME2 Project Team
4
+ * Copyright (C) 2008 Ruby-GNOME2 Project Team
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 2.1 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
+ * MA 02110-1301 USA
20
+ */
9
21
 
10
22
  #include "rbpoppler-private.h"
11
23
 
12
- #define SELF(self) (POPPLER_ANNOT(RVAL2GOBJ(self)))
13
-
14
- #define TYPE2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_ANNOT_TYPE))
15
- #define FLAG2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_ANNOT_FLAG))
16
- #define REPLY_TYPE2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_ANNOT_MARKUP_REPLY_TYPE))
17
- #define DATA_TYPE2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_ANNOT_EXTERNAL_DATA_TYPE))
18
- #define TEXT_ICON2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_ANNOT_TEXT_ICON))
19
- #define TEXT_STATE2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_ANNOT_TEXT_STATE))
20
- #define QUADDING2RVAL(obj) (GENUM2RVAL(obj, POPPLER_TYPE_ANNOT_FREE_TEXT_QUADDING))
21
- #define LINE2RVAL(obj) (BOXED2RVAL(obj, POPPLER_TYPE_ANNOT_CALLOUT_LINE))
22
- #define RVAL2LINE(obj) ((PopplerAnnotCalloutLine *)RVAL2BOXED(obj, POPPLER_TYPE_ANNOT_CALLOUT_LINE))
23
-
24
- static VALUE rb_cDate;
25
- static ID id_new;
26
-
24
+ #define RG_TARGET_NAMESPACE cAnnotation
25
+ #define SELF(self) (RVAL2POPPLERANNOT(self))
27
26
 
28
27
  static VALUE
29
- annot_get_annot_type(VALUE self)
28
+ rg_type(VALUE self)
30
29
  {
31
- return TYPE2RVAL(poppler_annot_get_annot_type(SELF(self)));
30
+ return POPPLERANNOTTYPE2RVAL(poppler_annot_get_annot_type(SELF(self)));
32
31
  }
33
32
 
34
33
  static VALUE
35
- annot_get_contents(VALUE self)
34
+ rg_contents(VALUE self)
36
35
  {
37
36
  return CSTR2RVAL_FREE(poppler_annot_get_contents(SELF(self)));
38
37
  }
39
38
 
40
39
  static VALUE
41
- annot_get_name(VALUE self)
40
+ rg_name(VALUE self)
42
41
  {
43
42
  return CSTR2RVAL_FREE(poppler_annot_get_name(SELF(self)));
44
43
  }
45
44
 
46
45
  static VALUE
47
- annot_get_modified(VALUE self)
46
+ rg_modified(VALUE self)
48
47
  {
49
48
  return CSTR2RVAL_FREE(poppler_annot_get_modified(SELF(self)));
50
49
  }
51
50
 
52
51
  static VALUE
53
- annot_get_flags(VALUE self)
54
- {
55
- return FLAG2RVAL(poppler_annot_get_flags(SELF(self)));
56
- }
57
-
58
- static VALUE
59
- annot_get_color(VALUE self)
60
- {
61
- return POPPLER_COLOR2RVAL_FREE(poppler_annot_get_color(SELF(self)));
62
- }
63
-
64
- /* PopplerAnnotMarkup */
65
- #undef SELF
66
- #define SELF(self) (POPPLER_ANNOT_MARKUP(RVAL2GOBJ(self)))
67
-
68
- static VALUE
69
- annot_markup_get_label(VALUE self)
70
- {
71
- return CSTR2RVAL_FREE(poppler_annot_markup_get_label(SELF(self)));
72
- }
73
-
74
- static VALUE
75
- annot_markup_get_popup_is_open(VALUE self)
76
- {
77
- return CBOOL2RVAL(poppler_annot_markup_get_popup_is_open(SELF(self)));
78
- }
79
-
80
- static VALUE
81
- annot_markup_get_opacity(VALUE self)
82
- {
83
- return rb_float_new(poppler_annot_markup_get_opacity(SELF(self)));
84
- }
85
-
86
- static VALUE
87
- annot_markup_get_date(VALUE self)
88
- {
89
- GDate *date;
90
- VALUE rb_date;
91
-
92
- date = poppler_annot_markup_get_date(SELF(self));
93
- rb_date = rb_funcall(rb_cDate, id_new, 3,
94
- UINT2NUM(g_date_get_year(date)),
95
- UINT2NUM(g_date_get_month(date)),
96
- UINT2NUM(g_date_get_day(date)));
97
- g_date_free(date);
98
- return rb_date;
99
- }
100
-
101
- static VALUE
102
- annot_markup_get_subject(VALUE self)
52
+ rg_flags(VALUE self)
103
53
  {
104
- return CSTR2RVAL_FREE(poppler_annot_markup_get_subject(SELF(self)));
54
+ return POPPLERANNOTFLAG2RVAL(poppler_annot_get_flags(SELF(self)));
105
55
  }
106
56
 
107
57
  static VALUE
108
- annot_markup_get_reply_to(VALUE self)
58
+ rg_color(VALUE self)
109
59
  {
110
- return REPLY_TYPE2RVAL(poppler_annot_markup_get_reply_to(SELF(self)));
111
- }
112
-
113
- static VALUE
114
- annot_markup_get_external_data(VALUE self)
115
- {
116
- return DATA_TYPE2RVAL(poppler_annot_markup_get_external_data(SELF(self)));
117
- }
118
-
119
- /* PopplerAnnotText */
120
- #undef SELF
121
- #define SELF(self) (POPPLER_ANNOT_TEXT(RVAL2GOBJ(self)))
122
-
123
- static VALUE
124
- annot_text_get_is_open(VALUE self)
125
- {
126
- return CBOOL2RVAL(poppler_annot_text_get_is_open(SELF(self)));
127
- }
128
-
129
- static VALUE
130
- annot_text_get_icon(VALUE self)
131
- {
132
- #if POPPLER_CHECK_VERSION(0, 9, 0)
133
- return CSTR2RVAL_FREE(poppler_annot_text_get_icon(SELF(self)));
134
- #else
135
- return TEXT_ICON2RVAL(poppler_annot_text_get_icon(SELF(self)));
136
- #endif
137
- }
138
-
139
- static VALUE
140
- annot_text_get_state(VALUE self)
141
- {
142
- return TEXT_STATE2RVAL(poppler_annot_text_get_state(SELF(self)));
143
- }
144
-
145
- /* PopplerAnnotFreeText */
146
- #undef SELF
147
- #define SELF(self) (POPPLER_ANNOT_FREE_TEXT(RVAL2GOBJ(self)))
148
-
149
- static VALUE
150
- annot_free_text_get_quadding(VALUE self)
151
- {
152
- return QUADDING2RVAL(poppler_annot_free_text_get_quadding(SELF(self)));
153
- }
154
-
155
- static VALUE
156
- annot_free_text_get_callout_line(VALUE self)
157
- {
158
- return LINE2RVAL(poppler_annot_free_text_get_callout_line(SELF(self)));
159
- }
160
-
161
- /* PopplerCalloutLine */
162
- static VALUE
163
- annot_callout_line_initialize(VALUE self, VALUE multiline, VALUE x1, VALUE y1,
164
- VALUE x2, VALUE y2, VALUE x3, VALUE y3)
165
- {
166
- PopplerAnnotCalloutLine *line;
167
-
168
- line = poppler_annot_callout_line_new();
169
- line->multiline = RVAL2CBOOL(multiline);
170
- line->x1 = NUM2DBL(x1);
171
- line->y1 = NUM2DBL(y1);
172
- line->x2 = NUM2DBL(x2);
173
- line->y2 = NUM2DBL(y2);
174
- line->x3 = NUM2DBL(x3);
175
- line->y3 = NUM2DBL(y3);
176
-
177
- G_INITIALIZE(self, line);
178
- return Qnil;
179
- }
180
-
181
- DEF_ACCESSOR(annot_callout_line, multiline, RVAL2LINE, CBOOL2RVAL, RVAL2CBOOL)
182
- DEF_ACCESSOR(annot_callout_line, x1, RVAL2LINE, rb_float_new, NUM2DBL)
183
- DEF_ACCESSOR(annot_callout_line, y1, RVAL2LINE, rb_float_new, NUM2DBL)
184
- DEF_ACCESSOR(annot_callout_line, x2, RVAL2LINE, rb_float_new, NUM2DBL)
185
- DEF_ACCESSOR(annot_callout_line, y2, RVAL2LINE, rb_float_new, NUM2DBL)
186
- DEF_ACCESSOR(annot_callout_line, x3, RVAL2LINE, rb_float_new, NUM2DBL)
187
- DEF_ACCESSOR(annot_callout_line, y3, RVAL2LINE, rb_float_new, NUM2DBL)
188
-
189
- static VALUE
190
- annot_callout_line_to_a(VALUE self)
191
- {
192
- PopplerAnnotCalloutLine *line;
193
-
194
- line = RVAL2LINE(self);
195
- return rb_ary_new3(7,
196
- CBOOL2RVAL(line->multiline),
197
- rb_float_new(line->x1),
198
- rb_float_new(line->y1),
199
- rb_float_new(line->x2),
200
- rb_float_new(line->y2),
201
- rb_float_new(line->x3),
202
- rb_float_new(line->y3));
203
- }
204
-
205
- static VALUE
206
- annot_callout_line_inspect(VALUE self)
207
- {
208
- VALUE inspected;
209
- gchar *info;
210
- PopplerAnnotCalloutLine *line;
211
-
212
- line = RVAL2LINE(self);
213
- inspected = rb_call_super(0, NULL);
214
- rb_str_resize(inspected, RSTRING_LEN(inspected) - 1);
215
- info = g_strdup_printf(": [%s, %g, %g, %g, %g, %g, %g]>",
216
- line->multiline ? "true" : "false",
217
- line->x1, line->y1,
218
- line->x2, line->y2,
219
- line->x3, line->y3);
220
- rb_str_cat2(inspected, info);
221
- g_free(info);
222
- return inspected;
60
+ return POPPLERCOLOR2RVAL_FREE(poppler_annot_get_color(SELF(self)));
223
61
  }
224
62
 
225
63
  void
226
64
  Init_poppler_annotation(VALUE mPoppler)
227
65
  {
228
- VALUE cAnnotation, cAnnotationMarkup, cAnnotationText;
229
- VALUE cAnnotationFreeText, cAnnotationCalloutLine;
230
-
231
- id_new = rb_intern("new");
232
- rb_cDate = rb_const_get(rb_cObject, rb_intern("Date"));
233
-
234
- cAnnotation = G_DEF_CLASS(POPPLER_TYPE_ANNOT, "Annotation", mPoppler);
235
- rb_define_method(cAnnotation, "type", annot_get_annot_type, 0);
236
- rb_define_method(cAnnotation, "contents", annot_get_contents, 0);
237
- rb_define_method(cAnnotation, "name", annot_get_name, 0);
238
- rb_define_method(cAnnotation, "modified", annot_get_modified, 0);
239
- rb_define_method(cAnnotation, "flags", annot_get_flags, 0);
240
- rb_define_method(cAnnotation, "color", annot_get_color, 0);
241
-
242
- cAnnotationMarkup = G_DEF_CLASS(POPPLER_TYPE_ANNOT_MARKUP,
243
- "AnnotationMarkup", mPoppler);
244
- rb_define_method(cAnnotationMarkup, "label", annot_markup_get_label, 0);
245
- rb_define_method(cAnnotationMarkup, "popup_is_open?",
246
- annot_markup_get_popup_is_open, 0);
247
- rb_define_method(cAnnotationMarkup, "opacity", annot_markup_get_opacity, 0);
248
- rb_define_method(cAnnotationMarkup, "date", annot_markup_get_date, 0);
249
- rb_define_method(cAnnotationMarkup, "subject", annot_markup_get_subject, 0);
250
- rb_define_method(cAnnotationMarkup, "reply_to",
251
- annot_markup_get_reply_to, 0);
252
- rb_define_method(cAnnotationMarkup, "external_data",
253
- annot_markup_get_external_data, 0);
254
-
255
- cAnnotationText = G_DEF_CLASS(POPPLER_TYPE_ANNOT_TEXT,
256
- "AnnotationText", mPoppler);
257
- rb_define_method(cAnnotationText, "open?", annot_text_get_is_open, 0);
258
- rb_define_method(cAnnotationText, "icon", annot_text_get_icon, 0);
259
- rb_define_method(cAnnotationText, "state", annot_text_get_state, 0);
260
-
261
- cAnnotationFreeText = G_DEF_CLASS(POPPLER_TYPE_ANNOT_FREE_TEXT,
262
- "AnnotationFreeText", mPoppler);
263
- rb_define_method(cAnnotationFreeText, "quadding",
264
- annot_free_text_get_quadding, 0);
265
- rb_define_method(cAnnotationFreeText, "callout_line",
266
- annot_free_text_get_callout_line, 0);
267
-
268
- cAnnotationCalloutLine = G_DEF_CLASS(POPPLER_TYPE_ANNOT_CALLOUT_LINE,
269
- "AnnotationCalloutLine", mPoppler);
270
- rb_define_method(cAnnotationCalloutLine, "initialize",
271
- annot_callout_line_initialize, 7);
272
-
273
- rb_define_method(cAnnotationCalloutLine, "multiline?",
274
- annot_callout_line_get_multiline, 0);
275
- rb_define_method(cAnnotationCalloutLine, "set_multiline",
276
- annot_callout_line_set_multiline, 1);
277
- rb_define_method(cAnnotationCalloutLine, "x1",
278
- annot_callout_line_get_x1, 0);
279
- rb_define_method(cAnnotationCalloutLine, "set_x1",
280
- annot_callout_line_set_x1, 1);
281
- rb_define_method(cAnnotationCalloutLine, "y1",
282
- annot_callout_line_get_y1, 0);
283
- rb_define_method(cAnnotationCalloutLine, "set_y1",
284
- annot_callout_line_set_y1, 1);
285
- rb_define_method(cAnnotationCalloutLine, "x2",
286
- annot_callout_line_get_x2, 0);
287
- rb_define_method(cAnnotationCalloutLine, "set_x2",
288
- annot_callout_line_set_x2, 2);
289
- rb_define_method(cAnnotationCalloutLine, "y2",
290
- annot_callout_line_get_y2, 0);
291
- rb_define_method(cAnnotationCalloutLine, "set_y2",
292
- annot_callout_line_set_y2, 2);
293
- rb_define_method(cAnnotationCalloutLine, "x3",
294
- annot_callout_line_get_x3, 0);
295
- rb_define_method(cAnnotationCalloutLine, "set_x3",
296
- annot_callout_line_set_x3, 3);
297
- rb_define_method(cAnnotationCalloutLine, "y3",
298
- annot_callout_line_get_y3, 0);
299
- rb_define_method(cAnnotationCalloutLine, "set_y3",
300
- annot_callout_line_set_y3, 3);
301
-
302
- rb_define_method(cAnnotationCalloutLine, "to_a", annot_callout_line_to_a, 0);
303
- rb_define_method(cAnnotationCalloutLine, "inspect",
304
- annot_callout_line_inspect, 0);
66
+ VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(POPPLER_TYPE_ANNOT, "Annotation", mPoppler);
305
67
 
306
- G_DEF_SETTERS(cAnnotationCalloutLine);
68
+ RG_DEF_METHOD(type, 0);
69
+ RG_DEF_METHOD(contents, 0);
70
+ RG_DEF_METHOD(name, 0);
71
+ RG_DEF_METHOD(modified, 0);
72
+ RG_DEF_METHOD(flags, 0);
73
+ RG_DEF_METHOD(color, 0);
307
74
  }