rwv2 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +515 -0
- data/History.txt +5 -0
- data/INSTALL +112 -0
- data/InstalledFiles +3 -0
- data/Manifest.txt +42 -0
- data/README +92 -0
- data/README.txt +73 -0
- data/Rakefile +28 -0
- data/config.save +12 -0
- data/ext/rwv2/MANIFEST +9 -0
- data/ext/rwv2/Makefile +150 -0
- data/ext/rwv2/extconf.rb +33 -0
- data/ext/rwv2/include/rwv2.h +42 -0
- data/ext/rwv2/include/rwv2_associated_strings.h +40 -0
- data/ext/rwv2/include/rwv2_handlers.h +129 -0
- data/ext/rwv2/include/rwv2_parser.h +58 -0
- data/ext/rwv2/include/rwv2_properties.h +149 -0
- data/ext/rwv2/mkmf.log +12 -0
- data/ext/rwv2/rwv2.cpp +294 -0
- data/ext/rwv2/rwv2.o +0 -0
- data/ext/rwv2/rwv2.so +0 -0
- data/ext/rwv2/rwv2_handlers.cpp +81 -0
- data/ext/rwv2/rwv2_handlers.o +0 -0
- data/ext/rwv2/rwv2_parser.cpp +76 -0
- data/ext/rwv2/rwv2_parser.o +0 -0
- data/ext/rwv2/rwv2_properties.cpp +218 -0
- data/ext/rwv2/rwv2_properties.o +0 -0
- data/install.rb +1098 -0
- data/lib/rwv2/handlers.rb +52 -0
- data/lib/rwv2/rwv2.rb +28 -0
- data/rwv2-0.2.3.patch +223 -0
- data/test/data/not_a_word_document.rtf +16 -0
- data/test/data/test.doc +0 -0
- data/test/data/test2.doc +0 -0
- data/test/data/test3.doc +0 -0
- data/test/data/test4.doc +0 -0
- data/test/data/test5.doc +0 -0
- data/test/data/test6.doc +0 -0
- data/test/data/test7.doc +0 -0
- data/test/data/test8.doc +0 -0
- data/test/data/test9.doc +0 -0
- data/test/test_parser.rb +644 -0
- metadata +130 -0
data/ext/rwv2/mkmf.log
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
have_library: checking for main() in -lwv2... -------------------- yes
|
2
|
+
|
3
|
+
"i686-pc-linux-gnu-gcc -o conftest -I. -I/usr/lib/ruby/1.8/i686-linux -I/home/zeno/.software/rwv2/ext/rwv2 -I./include -D_FILE_OFFSET_BITS=64 -Os -march=pentium4 -pipe -fno-strict-aliasing -fPIC conftest.c -L. -L/usr/lib -Wl,-R/usr/lib -L./lib -L. -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -rdynamic -Wl,-export-dynamic -lstdc++ -lruby18-static -lwv2 -lstdc++ -lpthread -lrt -ldl -lcrypt -lm -lc"
|
4
|
+
checked program was:
|
5
|
+
/* begin */
|
6
|
+
1: /*top*/
|
7
|
+
2: int main() { return 0; }
|
8
|
+
3: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
|
9
|
+
/* end */
|
10
|
+
|
11
|
+
--------------------
|
12
|
+
|
data/ext/rwv2/rwv2.cpp
ADDED
@@ -0,0 +1,294 @@
|
|
1
|
+
/* Rwv2 -- Microsoft Word Parser extension
|
2
|
+
Copyright (C) 2003 Hannes Wyss, ywesee
|
3
|
+
|
4
|
+
This library is free software; you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU Lesser General Public
|
6
|
+
License as published by the Free Software Foundation; either
|
7
|
+
version 2.1 of the License, or (at your option) any later version.
|
8
|
+
|
9
|
+
This library is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
Lesser General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU Lesser General Public
|
15
|
+
License along with this library; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
ywesee - intellectual capital connected
|
19
|
+
Winterthurerstrasse 52, CH-8006 Z�rich, Switzerland
|
20
|
+
hwyss@ywesee.com
|
21
|
+
*/
|
22
|
+
|
23
|
+
#include "ruby.h"
|
24
|
+
#include "rwv2.h"
|
25
|
+
#include "wv2/parserfactory.h"
|
26
|
+
#include "rwv2_parser.h"
|
27
|
+
#include "errno.h"
|
28
|
+
|
29
|
+
extern "C" {
|
30
|
+
|
31
|
+
VALUE mRwv2;
|
32
|
+
VALUE cRwv2Parser;
|
33
|
+
VALUE cRwv2Sep;
|
34
|
+
VALUE cRwv2Pap;
|
35
|
+
VALUE cRwv2Chp;
|
36
|
+
VALUE cRwv2Tap;
|
37
|
+
VALUE cRwv2Tc;
|
38
|
+
VALUE cRwv2Tab;
|
39
|
+
VALUE cRwv2Picf;
|
40
|
+
|
41
|
+
VALUE rwv2_create_parser(VALUE self, VALUE filename) {
|
42
|
+
VALUE parser;
|
43
|
+
Rwv2Parser * stub;
|
44
|
+
parser = Data_Make_Struct(cRwv2Parser, Rwv2Parser,
|
45
|
+
rwv2_parser_mark, rwv2_parser_free, stub);
|
46
|
+
stub->parser = wvWare::ParserFactory::createParser(STR2CSTR(filename));
|
47
|
+
if(!stub->parser)
|
48
|
+
{
|
49
|
+
if(errno == 0)
|
50
|
+
rb_raise(rb_eArgError,"'%s' is not a word-document.", STR2CSTR(filename));
|
51
|
+
else
|
52
|
+
rb_sys_fail(STR2CSTR(filename));
|
53
|
+
}
|
54
|
+
return parser;
|
55
|
+
}
|
56
|
+
VALUE rwv2_create_parser_from_content(VALUE self, VALUE content) {
|
57
|
+
VALUE parser;
|
58
|
+
Rwv2Parser * stub;
|
59
|
+
parser = Data_Make_Struct(cRwv2Parser, Rwv2Parser,
|
60
|
+
rwv2_parser_mark, rwv2_parser_free, stub);
|
61
|
+
long int len;
|
62
|
+
char * src = rb_str2cstr(content, &len);
|
63
|
+
stub->parser = wvWare::ParserFactory::createParser(
|
64
|
+
(const unsigned char *) src, len);
|
65
|
+
if(!stub->parser)
|
66
|
+
{
|
67
|
+
rb_raise(rb_eArgError,"Input is not a word-document.");
|
68
|
+
}
|
69
|
+
return parser;
|
70
|
+
}
|
71
|
+
void Init_rwv2() {
|
72
|
+
|
73
|
+
/* module Rwv2 */
|
74
|
+
mRwv2 = rb_define_module("Rwv2");
|
75
|
+
rb_define_module_function(mRwv2, "create_parser",
|
76
|
+
(VALUE (*)(...))rwv2_create_parser, 1);
|
77
|
+
rb_define_module_function(mRwv2, "create_parser_from_content",
|
78
|
+
(VALUE (*)(...))rwv2_create_parser_from_content, 1);
|
79
|
+
rb_define_const(mRwv2, "HEADER_EVEN", INT2FIX(0x01));
|
80
|
+
rb_define_const(mRwv2, "HEADER_ODD", INT2FIX(0x02));
|
81
|
+
rb_define_const(mRwv2, "FOOTER_EVEN", INT2FIX(0x04));
|
82
|
+
rb_define_const(mRwv2, "FOOTER_ODD", INT2FIX(0x08));
|
83
|
+
rb_define_const(mRwv2, "HEADER_FIRST", INT2FIX(0x10));
|
84
|
+
rb_define_const(mRwv2, "FOOTER_FIRST", INT2FIX(0x20));
|
85
|
+
rb_define_const(mRwv2, "ALIGN_LEFT", CHR2FIX(0));
|
86
|
+
rb_define_const(mRwv2, "ALIGN_CENTER", CHR2FIX(1));
|
87
|
+
rb_define_const(mRwv2, "ALIGN_RIGHT", CHR2FIX(2));
|
88
|
+
rb_define_const(mRwv2, "ALIGN_JUSTIFY", CHR2FIX(3));
|
89
|
+
|
90
|
+
/* class Rwv2::Parser */
|
91
|
+
cRwv2Parser = rb_define_class_under(mRwv2, "Parser", rb_cObject);
|
92
|
+
rb_define_method(cRwv2Parser, "is_ok?",
|
93
|
+
(VALUE (*)(...)) rwv2_parser_is_ok, 0);
|
94
|
+
rb_define_method(cRwv2Parser, "parse",
|
95
|
+
(VALUE (*)(...)) rwv2_parser_parse, 0);
|
96
|
+
rb_define_method(cRwv2Parser, "set_inline_replacement_handler",
|
97
|
+
(VALUE (*)(...)) rwv2_parser_set_inline_replacement_handler, 1);
|
98
|
+
rb_define_method(cRwv2Parser, "set_subdocument_handler",
|
99
|
+
(VALUE (*)(...)) rwv2_parser_set_subdocument_handler, 1);
|
100
|
+
rb_define_method(cRwv2Parser, "set_table_handler",
|
101
|
+
(VALUE (*)(...)) rwv2_parser_set_table_handler, 1);
|
102
|
+
rb_define_method(cRwv2Parser, "set_text_handler",
|
103
|
+
(VALUE (*)(...)) rwv2_parser_set_text_handler, 1);
|
104
|
+
|
105
|
+
/* class Rwv2::SectionProperties */
|
106
|
+
cRwv2Sep = rb_define_class_under(mRwv2, "SectionProperties", rb_cObject);
|
107
|
+
rb_define_method(cRwv2Sep, "break_code",
|
108
|
+
(VALUE (*)(...)) rwv2_sep_break_code, 0);
|
109
|
+
rb_define_const(cRwv2Sep, "BREAK_NONE", Qfalse);
|
110
|
+
rb_define_const(cRwv2Sep, "BREAK_COLUMN", CHR2FIX(1));
|
111
|
+
rb_define_const(cRwv2Sep, "BREAK_PAGE", CHR2FIX(2));
|
112
|
+
rb_define_const(cRwv2Sep, "BREAK_EVEN", CHR2FIX(3));
|
113
|
+
rb_define_const(cRwv2Sep, "BREAK_ODD", CHR2FIX(4));
|
114
|
+
rb_define_method(cRwv2Sep, "title_page?",
|
115
|
+
(VALUE (*)(...)) rwv2_sep_title_page, 0);
|
116
|
+
rb_define_method(cRwv2Sep, "page_number_format",
|
117
|
+
(VALUE (*)(...)) rwv2_sep_page_number_format, 0);
|
118
|
+
rb_define_const(cRwv2Sep, "NUMBER_ARABIC", CHR2FIX(0));
|
119
|
+
rb_define_const(cRwv2Sep, "NUMBER_ROMAN_UPPER", CHR2FIX(1));
|
120
|
+
rb_define_const(cRwv2Sep, "NUMBER_ROMAN_LOWER", CHR2FIX(2));
|
121
|
+
rb_define_const(cRwv2Sep, "NUMBER_LETTER_UPPER", CHR2FIX(3));
|
122
|
+
rb_define_const(cRwv2Sep, "NUMBER_LETTER_LOWER", CHR2FIX(4));
|
123
|
+
rb_define_method(cRwv2Sep, "unlocked?",
|
124
|
+
(VALUE (*)(...)) rwv2_sep_unlocked, 0);
|
125
|
+
rb_define_method(cRwv2Sep, "page_number_restart?",
|
126
|
+
(VALUE (*)(...)) rwv2_sep_page_number_restart, 0);
|
127
|
+
rb_define_method(cRwv2Sep, "endnote?",
|
128
|
+
(VALUE (*)(...)) rwv2_sep_endnote, 0);
|
129
|
+
rb_define_method(cRwv2Sep, "line_numbering_code",
|
130
|
+
(VALUE (*)(...)) rwv2_sep_line_numbering_code, 0);
|
131
|
+
rb_define_const(cRwv2Sep, "LINE_NUMBERING_PER_PAGE", CHR2FIX(0));
|
132
|
+
rb_define_const(cRwv2Sep, "LINE_NUMBERING_RESTART", CHR2FIX(1));
|
133
|
+
rb_define_const(cRwv2Sep, "LINE_NUMBERING_CONTINUE", CHR2FIX(2));
|
134
|
+
rb_define_method(cRwv2Sep, "line_numbering_modulus",
|
135
|
+
(VALUE (*)(...)) rwv2_sep_line_numbering_modulus, 0);
|
136
|
+
rb_define_method(cRwv2Sep, "columns",
|
137
|
+
(VALUE (*)(...)) rwv2_sep_columns, 0);
|
138
|
+
|
139
|
+
/* class Rwv2::ParagraphProperties */
|
140
|
+
cRwv2Pap = rb_define_class_under(mRwv2, "ParagraphProperties", rb_cObject);
|
141
|
+
rb_define_method(cRwv2Pap, "align",
|
142
|
+
(VALUE (*)(...)) rwv2_pap_justify, 0);
|
143
|
+
rb_define_method(cRwv2Pap, "keep?",
|
144
|
+
(VALUE (*)(...)) rwv2_pap_keep, 0);
|
145
|
+
rb_define_method(cRwv2Pap, "keep_with_next?",
|
146
|
+
(VALUE (*)(...)) rwv2_pap_keep_follow, 0);
|
147
|
+
rb_define_method(cRwv2Pap, "page_break_before?",
|
148
|
+
(VALUE (*)(...)) rwv2_pap_page_break_before, 0);
|
149
|
+
rb_define_method(cRwv2Pap, "widow_control?",
|
150
|
+
(VALUE (*)(...)) rwv2_pap_widow_control, 0);
|
151
|
+
rb_define_method(cRwv2Pap, "indent_right",
|
152
|
+
(VALUE (*)(...)) rwv2_pap_indent_right, 0);
|
153
|
+
rb_define_method(cRwv2Pap, "indent_left",
|
154
|
+
(VALUE (*)(...)) rwv2_pap_indent_left, 0);
|
155
|
+
rb_define_method(cRwv2Pap, "indent_first_line",
|
156
|
+
(VALUE (*)(...)) rwv2_pap_indent_first_line, 0);
|
157
|
+
rb_define_method(cRwv2Pap, "tab_descriptors",
|
158
|
+
(VALUE (*)(...)) rwv2_pap_tab_descriptors, 0);
|
159
|
+
|
160
|
+
/* class Rwv2::CharacterProperties */
|
161
|
+
cRwv2Chp = rb_define_class_under(mRwv2, "CharacterProperties", rb_cObject);
|
162
|
+
rb_define_method(cRwv2Chp, "bold?",
|
163
|
+
(VALUE (*)(...)) rwv2_chp_bold, 0);
|
164
|
+
rb_define_method(cRwv2Chp, "italic?",
|
165
|
+
(VALUE (*)(...)) rwv2_chp_italic, 0);
|
166
|
+
rb_define_method(cRwv2Chp, "rev_mark?",
|
167
|
+
(VALUE (*)(...)) rwv2_chp_rev_mark, 0);
|
168
|
+
rb_define_method(cRwv2Chp, "rev_mark_del?",
|
169
|
+
(VALUE (*)(...)) rwv2_chp_rev_mark_del, 0);
|
170
|
+
rb_define_method(cRwv2Chp, "outline?",
|
171
|
+
(VALUE (*)(...)) rwv2_chp_outline, 0);
|
172
|
+
rb_define_method(cRwv2Chp, "small_caps?",
|
173
|
+
(VALUE (*)(...)) rwv2_chp_small_caps, 0);
|
174
|
+
rb_define_method(cRwv2Chp, "caps?",
|
175
|
+
(VALUE (*)(...)) rwv2_chp_caps, 0);
|
176
|
+
rb_define_method(cRwv2Chp, "special_char?",
|
177
|
+
(VALUE (*)(...)) rwv2_chp_special_char, 0);
|
178
|
+
rb_define_method(cRwv2Chp, "strikethrough?",
|
179
|
+
(VALUE (*)(...)) rwv2_chp_strikethrough, 0);
|
180
|
+
rb_define_method(cRwv2Chp, "shadow?",
|
181
|
+
(VALUE (*)(...)) rwv2_chp_shadow, 0);
|
182
|
+
rb_define_method(cRwv2Chp, "lowercase?",
|
183
|
+
(VALUE (*)(...)) rwv2_chp_lowercase, 0);
|
184
|
+
rb_define_method(cRwv2Chp, "emboss?",
|
185
|
+
(VALUE (*)(...)) rwv2_chp_emboss, 0);
|
186
|
+
rb_define_method(cRwv2Chp, "imprint?",
|
187
|
+
(VALUE (*)(...)) rwv2_chp_imprint, 0);
|
188
|
+
rb_define_method(cRwv2Chp, "double_strikethrough?",
|
189
|
+
(VALUE (*)(...)) rwv2_chp_double_strikethrough, 0);
|
190
|
+
rb_define_method(cRwv2Chp, "position",
|
191
|
+
(VALUE (*)(...)) rwv2_chp_position, 0);
|
192
|
+
rb_define_const(cRwv2Chp, "POSITION_NORMAL", Qfalse);
|
193
|
+
rb_define_const(cRwv2Chp, "POSITION_SUPERSCRIPT", CHR2FIX(1));
|
194
|
+
rb_define_const(cRwv2Chp, "POSITION_SUBSCRIPT", CHR2FIX(2));
|
195
|
+
rb_define_method(cRwv2Chp, "underline",
|
196
|
+
(VALUE (*)(...)) rwv2_chp_underline, 0);
|
197
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_NONE", Qfalse);
|
198
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_SINGLE", CHR2FIX(1));
|
199
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_BY_WORD", CHR2FIX(2));
|
200
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_DOUBLE", CHR2FIX(3));
|
201
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_DOTTED", CHR2FIX(4));
|
202
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_THICK", CHR2FIX(6));
|
203
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_DASH", CHR2FIX(7));
|
204
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_DOT_DASH", CHR2FIX(9));
|
205
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_DOT_DOT_DASH", CHR2FIX(10));
|
206
|
+
rb_define_const(cRwv2Chp, "UNDERLINE_WAVE", CHR2FIX(11));
|
207
|
+
rb_define_method(cRwv2Chp, "scale",
|
208
|
+
(VALUE (*)(...)) rwv2_chp_scale, 0);
|
209
|
+
rb_define_method(cRwv2Chp, "fontsize",
|
210
|
+
(VALUE (*)(...)) rwv2_chp_font_hps, 0);
|
211
|
+
|
212
|
+
/* class Rwv2::TableProperties */
|
213
|
+
cRwv2Tap = rb_define_class_under(mRwv2, "TableProperties", rb_cObject);
|
214
|
+
rb_define_method(cRwv2Tap, "align",
|
215
|
+
(VALUE (*)(...)) rwv2_tap_justify, 0);
|
216
|
+
rb_define_method(cRwv2Tap, "gap_half",
|
217
|
+
(VALUE (*)(...)) rwv2_tap_gap_half, 0);
|
218
|
+
rb_define_method(cRwv2Tap, "row_height",
|
219
|
+
(VALUE (*)(...)) rwv2_tap_row_height, 0);
|
220
|
+
rb_define_method(cRwv2Tap, "cant_split?",
|
221
|
+
(VALUE (*)(...)) rwv2_tap_cant_split, 0);
|
222
|
+
rb_define_method(cRwv2Tap, "table_header?",
|
223
|
+
(VALUE (*)(...)) rwv2_tap_table_header, 0);
|
224
|
+
rb_define_method(cRwv2Tap, "row_cells",
|
225
|
+
(VALUE (*)(...)) rwv2_tap_row_cells, 0);
|
226
|
+
rb_define_method(cRwv2Tap, "cell_boundaries",
|
227
|
+
(VALUE (*)(...)) rwv2_tap_cell_boundaries, 0);
|
228
|
+
rb_define_method(cRwv2Tap, "cell_descriptors",
|
229
|
+
(VALUE (*)(...)) rwv2_tap_cell_descriptors, 0);
|
230
|
+
|
231
|
+
/* class Rwv2::TableProperties::CellDescriptor */
|
232
|
+
cRwv2Tc = rb_define_class_under(cRwv2Tap, "CellDescriptor", rb_cObject);
|
233
|
+
rb_define_method(cRwv2Tc, "first_merged?",
|
234
|
+
(VALUE (*)(...)) rwv2_tc_first_merged, 0);
|
235
|
+
rb_define_method(cRwv2Tc, "merged?",
|
236
|
+
(VALUE (*)(...)) rwv2_tc_merged, 0);
|
237
|
+
rb_define_method(cRwv2Tc, "vertical?",
|
238
|
+
(VALUE (*)(...)) rwv2_tc_vertical, 0);
|
239
|
+
rb_define_method(cRwv2Tc, "backward?",
|
240
|
+
(VALUE (*)(...)) rwv2_tc_backward, 0);
|
241
|
+
rb_define_method(cRwv2Tc, "rotate_font?",
|
242
|
+
(VALUE (*)(...)) rwv2_tc_rotate_font, 0);
|
243
|
+
rb_define_method(cRwv2Tc, "vertical_merged?",
|
244
|
+
(VALUE (*)(...)) rwv2_tc_vertical_merged, 0);
|
245
|
+
rb_define_method(cRwv2Tc, "vertical_restart?",
|
246
|
+
(VALUE (*)(...)) rwv2_tc_vertical_restart, 0);
|
247
|
+
rb_define_method(cRwv2Tc, "vertical_align",
|
248
|
+
(VALUE (*)(...)) rwv2_tc_vertical_align, 0);
|
249
|
+
rb_define_const(cRwv2Tc, "ALIGN_TOP", CHR2FIX(0));
|
250
|
+
rb_define_const(cRwv2Tc, "ALIGN_CENTER", CHR2FIX(1));
|
251
|
+
rb_define_const(cRwv2Tc, "ALIGN_BOTTOM", CHR2FIX(2));
|
252
|
+
|
253
|
+
/* class Rwv2::TabDescriptor */
|
254
|
+
cRwv2Tab = rb_define_class_under(mRwv2, "TabDescriptor", rb_cObject);
|
255
|
+
rb_define_method(cRwv2Tab, "position",
|
256
|
+
(VALUE (*)(...)) rwv2_tab_position, 0);
|
257
|
+
rb_define_method(cRwv2Tab, "align",
|
258
|
+
(VALUE (*)(...)) rwv2_tab_justify, 0);
|
259
|
+
rb_define_const(cRwv2Tab, "ALIGN_LEFT", CHR2FIX(0));
|
260
|
+
rb_define_const(cRwv2Tab, "ALIGN_CENTER", CHR2FIX(1));
|
261
|
+
rb_define_const(cRwv2Tab, "ALIGN_RIGHT", CHR2FIX(2));
|
262
|
+
rb_define_const(cRwv2Tab, "ALIGN_DECIMAL", CHR2FIX(3));
|
263
|
+
rb_define_const(cRwv2Tab, "ALIGN_BAR", CHR2FIX(4));
|
264
|
+
|
265
|
+
/* class Rwv2::PictureDescriptor */
|
266
|
+
cRwv2Picf = rb_define_class_under(mRwv2, "PictureDescriptor", rb_cObject);
|
267
|
+
rb_define_method(cRwv2Picf, "blob",
|
268
|
+
(VALUE (*)(...)) rwv2_picf_blob, 0);
|
269
|
+
rb_define_method(cRwv2Picf, "mapping_mode",
|
270
|
+
(VALUE (*)(...)) rwv2_picf_mapping_mode, 0);
|
271
|
+
rb_define_const(cRwv2Picf, "TIFF", CHR2FIX(98));
|
272
|
+
rb_define_const(cRwv2Picf, "BMP", CHR2FIX(99));
|
273
|
+
rb_define_method(cRwv2Picf, "display_width",
|
274
|
+
(VALUE (*)(...)) rwv2_picf_display_width, 0);
|
275
|
+
rb_define_method(cRwv2Picf, "display_height",
|
276
|
+
(VALUE (*)(...)) rwv2_picf_display_height, 0);
|
277
|
+
rb_define_method(cRwv2Picf, "scaling_vertical",
|
278
|
+
(VALUE (*)(...)) rwv2_picf_scaling_vertical, 0);
|
279
|
+
rb_define_method(cRwv2Picf, "scaling_horizontal",
|
280
|
+
(VALUE (*)(...)) rwv2_picf_scaling_horizontal, 0);
|
281
|
+
rb_define_method(cRwv2Picf, "crop_left",
|
282
|
+
(VALUE (*)(...)) rwv2_picf_crop_left, 0);
|
283
|
+
rb_define_method(cRwv2Picf, "crop_top",
|
284
|
+
(VALUE (*)(...)) rwv2_picf_crop_top, 0);
|
285
|
+
rb_define_method(cRwv2Picf, "crop_right",
|
286
|
+
(VALUE (*)(...)) rwv2_picf_crop_right, 0);
|
287
|
+
rb_define_method(cRwv2Picf, "crop_bottom",
|
288
|
+
(VALUE (*)(...)) rwv2_picf_crop_bottom, 0);
|
289
|
+
rb_define_method(cRwv2Picf, "is_bitmap?",
|
290
|
+
(VALUE (*)(...)) rwv2_picf_is_bitmap, 0);
|
291
|
+
rb_define_method(cRwv2Picf, "is_active_ole_object?",
|
292
|
+
(VALUE (*)(...)) rwv2_picf_is_active_ole, 0);
|
293
|
+
}
|
294
|
+
} // extern "C"
|
data/ext/rwv2/rwv2.o
ADDED
Binary file
|
data/ext/rwv2/rwv2.so
ADDED
Binary file
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/* Rwv2 -- Microsoft Word Parser extension
|
2
|
+
Copyright (C) 2003 Hannes Wyss, ywesee
|
3
|
+
|
4
|
+
This library is free software; you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU Lesser General Public
|
6
|
+
License as published by the Free Software Foundation; either
|
7
|
+
version 2.1 of the License, or (at your option) any later version.
|
8
|
+
|
9
|
+
This library is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
Lesser General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU Lesser General Public
|
15
|
+
License along with this library; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
ywesee - intellectual capital connected
|
19
|
+
Winterthurerstrasse 52, CH-8006 Z�rich, Switzerland
|
20
|
+
hwyss@ywesee.com
|
21
|
+
*/
|
22
|
+
|
23
|
+
#include "ruby.h"
|
24
|
+
|
25
|
+
#include "rwv2.h"
|
26
|
+
#include "rwv2_handlers.h"
|
27
|
+
|
28
|
+
extern "C" {
|
29
|
+
|
30
|
+
void Rwv2TableHandler::tableRowStart(wvWare::SharedPtr<const wvWare::Word97::TAP> tap) {
|
31
|
+
Rwv2Tap * stub;
|
32
|
+
SVALUE rb_tap;
|
33
|
+
rb_tap = Data_Make_Struct(cRwv2Tap, Rwv2Tap, 0, rwv2_tap_free, stub);
|
34
|
+
stub->wv_tap = tap;
|
35
|
+
rb_funcall(m_rb_handler, rb_intern("row_start"), 1, rb_tap);
|
36
|
+
};
|
37
|
+
|
38
|
+
void Rwv2TextHandler::sectionStart(wvWare::SharedPtr<const wvWare::Word97::SEP> sep) {
|
39
|
+
Rwv2Sep * stub;
|
40
|
+
SVALUE rb_sep;
|
41
|
+
rb_sep = Data_Make_Struct(cRwv2Sep, Rwv2Sep, 0, rwv2_sep_free, stub);
|
42
|
+
stub->wv_sep = sep;
|
43
|
+
rb_funcall(m_rb_handler, rb_intern("section_start"), 1, rb_sep);
|
44
|
+
}
|
45
|
+
|
46
|
+
void Rwv2TextHandler::paragraphStart(wvWare::SharedPtr<const wvWare::ParagraphProperties> pap) {
|
47
|
+
Rwv2Pap * stub;
|
48
|
+
SVALUE rb_pap;
|
49
|
+
rb_pap = Data_Make_Struct(cRwv2Pap, Rwv2Pap, 0, free, stub);
|
50
|
+
stub->wv_pap = pap;
|
51
|
+
rb_funcall(m_rb_handler, rb_intern("paragraph_start"), 1, rb_pap);
|
52
|
+
}
|
53
|
+
|
54
|
+
void Rwv2TextHandler::runOfText(const wvWare::UString & text,
|
55
|
+
wvWare::SharedPtr<const wvWare::Word97::CHP> chp) {
|
56
|
+
SVALUE rb_str = rb_str_new((char *) text.data(), 2 * text.length());
|
57
|
+
SVALUE rb_chp = wrap_chp(chp);
|
58
|
+
rb_funcall(m_rb_handler, rb_intern("run_of_text"), 2, rb_str, rb_chp);
|
59
|
+
};
|
60
|
+
|
61
|
+
void Rwv2TextHandler::pictureData( wvWare::SharedPtr<const wvWare::Word97::PICF> picf,
|
62
|
+
wvWare::U8 * buffer ) {
|
63
|
+
long len = picf->lcb - picf->cbHeader;
|
64
|
+
SVALUE rb_picf;
|
65
|
+
Rwv2Picf * stub;
|
66
|
+
rb_picf = Data_Make_Struct(cRwv2Picf, Rwv2Picf,
|
67
|
+
rwv2_picf_mark, rwv2_picf_free, stub);
|
68
|
+
stub->wv_picf = picf;
|
69
|
+
stub->rb_blob = rb_str_new((const char *)buffer, len);
|
70
|
+
rb_funcall(m_rb_handler, rb_intern("picture"), 1, rb_picf);
|
71
|
+
}
|
72
|
+
|
73
|
+
VALUE Rwv2TextHandler::wrap_chp(wvWare::SharedPtr<const wvWare::Word97::CHP> chp) {
|
74
|
+
Rwv2Chp * stub;
|
75
|
+
SVALUE rb_chp;
|
76
|
+
rb_chp = Data_Make_Struct(cRwv2Chp, Rwv2Chp, 0, rwv2_chp_free, stub);
|
77
|
+
stub->wv_chp = chp;
|
78
|
+
return rb_chp;
|
79
|
+
}
|
80
|
+
|
81
|
+
}; // extern "C"
|
Binary file
|
@@ -0,0 +1,76 @@
|
|
1
|
+
/* Rwv2 -- Microsoft Word Parser extension
|
2
|
+
Copyright (C) 2003 Hannes Wyss, ywesee
|
3
|
+
|
4
|
+
This library is free software; you can redistribute it and/or
|
5
|
+
modify it under the terms of the GNU Lesser General Public
|
6
|
+
License as published by the Free Software Foundation; either
|
7
|
+
version 2.1 of the License, or (at your option) any later version.
|
8
|
+
|
9
|
+
This library is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
+
Lesser General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU Lesser General Public
|
15
|
+
License along with this library; if not, write to the Free Software
|
16
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
ywesee - intellectual capital connected
|
19
|
+
Winterthurerstrasse 52, CH-8006 Z�rich, Switzerland
|
20
|
+
hwyss@ywesee.com
|
21
|
+
*/
|
22
|
+
|
23
|
+
#include "ruby.h"
|
24
|
+
#include "rwv2_parser.h"
|
25
|
+
|
26
|
+
extern "C" {
|
27
|
+
|
28
|
+
VALUE rwv2_parser_is_ok(VALUE self) {
|
29
|
+
Rwv2Parser * stub;
|
30
|
+
Data_Get_Struct(self, Rwv2Parser, stub);
|
31
|
+
if(stub->parser->isOk())
|
32
|
+
return Qtrue;
|
33
|
+
else
|
34
|
+
return Qfalse;
|
35
|
+
}
|
36
|
+
VALUE rwv2_parser_parse(VALUE self) {
|
37
|
+
Rwv2Parser * stub;
|
38
|
+
Data_Get_Struct(self, Rwv2Parser, stub);
|
39
|
+
if(stub->parser->parse())
|
40
|
+
return Qtrue;
|
41
|
+
else
|
42
|
+
return Qfalse;
|
43
|
+
}
|
44
|
+
|
45
|
+
#define SET_HANDLER(t_rb, t_wv) \
|
46
|
+
VALUE rwv2_parser_set_ ## t_rb ## _handler(VALUE self, VALUE rb_handler) { \
|
47
|
+
Rwv2 ## t_wv ## Handler * handler = new Rwv2 ## t_wv ## Handler(rb_handler); \
|
48
|
+
Rwv2Parser * stub; \
|
49
|
+
Data_Get_Struct(self, Rwv2Parser, stub); \
|
50
|
+
stub->rb_ ## t_rb ## _handler = rb_handler; \
|
51
|
+
stub->wv_ ## t_rb ## _handler = handler; \
|
52
|
+
stub->parser->set ## t_wv ## Handler(handler); \
|
53
|
+
return Qnil; \
|
54
|
+
}
|
55
|
+
|
56
|
+
SET_HANDLER(inline_replacement, InlineReplacement)
|
57
|
+
SET_HANDLER(subdocument, SubDocument)
|
58
|
+
SET_HANDLER(table, Table)
|
59
|
+
SET_HANDLER(text, Text)
|
60
|
+
|
61
|
+
void rwv2_parser_mark(Rwv2Parser * stub) {
|
62
|
+
rb_gc_mark(stub->rb_inline_replacement_handler);
|
63
|
+
rb_gc_mark(stub->rb_subdocument_handler);
|
64
|
+
rb_gc_mark(stub->rb_table_handler);
|
65
|
+
rb_gc_mark(stub->rb_text_handler);
|
66
|
+
}
|
67
|
+
void rwv2_parser_free(Rwv2Parser * stub) {
|
68
|
+
delete stub->wv_inline_replacement_handler;
|
69
|
+
delete stub->wv_subdocument_handler;
|
70
|
+
delete stub->wv_table_handler;
|
71
|
+
delete stub->wv_text_handler;
|
72
|
+
//delete stub->parser;
|
73
|
+
free(stub);
|
74
|
+
}
|
75
|
+
|
76
|
+
} // extern "C"
|