rwv2 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Rwv2 -- Microsoft Word Parser extension
4
+ # Copyright (C) 2003 Hannes Wyss, ywesee - intellectual capital connected
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ #
20
+ # ywesee - intellectual capital connected
21
+ # Winterthurerstrasse 52, CH-8006 Z�rich, Switzerland
22
+ # hwyss@ywesee.com
23
+ #
24
+ # extconf.rb -- Rwv2 -- 21.8.2003 -- hwyss@ywesee.com
25
+
26
+ require 'mkmf'
27
+
28
+ $libs = append_library($libs, "stdc++")
29
+ dir_config('wv2')
30
+ dir_config('rwv2', '.')
31
+ if(have_library('wv2'))
32
+ create_makefile('rwv2')
33
+ end
@@ -0,0 +1,42 @@
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
+ #ifndef RWV2_H
24
+ #define RWV2_H
25
+
26
+ #define SVALUE volatile VALUE
27
+
28
+ extern "C" {
29
+
30
+ extern VALUE mRwv2;
31
+ extern VALUE cRwv2Parser;
32
+ extern VALUE cRwv2Sep;
33
+ extern VALUE cRwv2Pap;
34
+ extern VALUE cRwv2Chp;
35
+ extern VALUE cRwv2Tap;
36
+ extern VALUE cRwv2Tc;
37
+ extern VALUE cRwv2Tab;
38
+ extern VALUE cRwv2Picf;
39
+
40
+ } // extern "C"
41
+
42
+ #endif
@@ -0,0 +1,40 @@
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
+ #ifndef RWV2_ASSOCIATED_STRINGS_H
24
+ #define RWV2_ASSOCIATED_STRINGS_H
25
+
26
+ #include "ustring.h"
27
+ #include "associatedstrings.h"
28
+
29
+ namespace Rwv2 {
30
+ class AssociatedStrings {
31
+ public:
32
+ const char * title;
33
+ AssociatedStrings(wvWare::AssociatedStrings * strings) {
34
+ wvWare::UString utitle = strings->title();
35
+ wvWare::CString ctitle = utitle.cstring();
36
+ title = ctitle.c_str();
37
+ };
38
+ };
39
+ } // namespace Rwv2
40
+ #endif
@@ -0,0 +1,129 @@
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
+ #ifndef RWV2_HANDLERS_H
24
+ #define RWV2_HANDLERS_H
25
+
26
+
27
+ #include "wv2/global.h"
28
+ #include "wv2/handlers.h"
29
+ #include "wv2/sharedptr.h"
30
+ #include "wv2/ustring.h"
31
+ #include "wv2/word97_generated.h"
32
+ #include "wv2/paragraphproperties.h"
33
+
34
+
35
+ #include "rwv2.h"
36
+ #include "rwv2_properties.h"
37
+
38
+ extern "C" {
39
+
40
+ #define RB_REPLACE(target, funcname, dflt) \
41
+ if(rb_funcall(target, rb_intern("respond_to?"), 1, rb_str_new2(funcname)) == Qfalse) { \
42
+ return (wvWare::U8) * dflt; \
43
+ } \
44
+ VALUE val = rb_funcall(target, rb_intern(funcname), 0); \
45
+ long len; \
46
+ char * cstr = rb_str2cstr(val, &len); \
47
+ if(len != 1) { \
48
+ rb_raise(rb_eRuntimeError, "InlineReplacementHandler#%s() must return single Character!", funcname); \
49
+ } \
50
+ return (wvWare::U8) * cstr;
51
+
52
+ class Rwv2InlineReplacementHandler : public wvWare::InlineReplacementHandler {
53
+ private:
54
+ VALUE m_rb_handler;
55
+ public:
56
+ Rwv2InlineReplacementHandler(VALUE rb_handler) : m_rb_handler(rb_handler) {};
57
+ wvWare::U8 tab() {
58
+ RB_REPLACE(m_rb_handler, "tab", "\t");
59
+ };
60
+ wvWare::U8 hardLineBreak() {
61
+ RB_REPLACE(m_rb_handler, "hard_line_break", "\v");
62
+ };
63
+ wvWare::U8 columnBreak() {
64
+ RB_REPLACE(m_rb_handler, "column_break", "\016");
65
+ };
66
+ wvWare::U8 nonBreakingHyphen() {
67
+ RB_REPLACE(m_rb_handler, "non_breaking_hyphen", "\036");
68
+ };
69
+ wvWare::U8 nonRequiredHyphen() {
70
+ RB_REPLACE(m_rb_handler, "non_required_hyphen", "\037");
71
+ };
72
+ wvWare::U8 nonBreakingSpace() {
73
+ RB_REPLACE(m_rb_handler, "non_breaking_space", "\240");
74
+ };
75
+ };
76
+
77
+ #define RB_DELEGATE(funcname_wv, funcname_rb) \
78
+ void funcname_wv() {\
79
+ rb_funcall(m_rb_handler, rb_intern(funcname_rb), 0); \
80
+ }
81
+
82
+ class Rwv2SubDocumentHandler : public wvWare::SubDocumentHandler {
83
+ public:
84
+ Rwv2SubDocumentHandler(VALUE rb_handler) : m_rb_handler(rb_handler) {};
85
+ RB_DELEGATE(bodyStart, "body_start")
86
+ RB_DELEGATE(bodyEnd, "body_end")
87
+ RB_DELEGATE(footnoteStart, "footnote_start")
88
+ RB_DELEGATE(footnoteEnd, "footnote_end")
89
+ RB_DELEGATE(headersStart, "headers_start")
90
+ RB_DELEGATE(headersEnd, "headers_end")
91
+ void headerStart(wvWare::HeaderData::Type type) {
92
+ VALUE rb_type = INT2FIX((int)type);
93
+ rb_funcall(m_rb_handler, rb_intern("header_start"), 1, rb_type);
94
+ }
95
+ RB_DELEGATE(headerEnd, "header_end")
96
+ private:
97
+ VALUE m_rb_handler;
98
+ };
99
+
100
+ class Rwv2TableHandler : public wvWare::TableHandler {
101
+ public:
102
+ Rwv2TableHandler(VALUE rb_handler) : m_rb_handler(rb_handler) {};
103
+ void tableRowStart(wvWare::SharedPtr<const wvWare::Word97::TAP> tap);
104
+ RB_DELEGATE(tableRowEnd, "row_end")
105
+ RB_DELEGATE(tableCellStart, "cell_start")
106
+ RB_DELEGATE(tableCellEnd, "cell_end")
107
+ private:
108
+ VALUE m_rb_handler;
109
+ };
110
+
111
+ class Rwv2TextHandler : public wvWare::TextHandler {
112
+ public:
113
+ Rwv2TextHandler(VALUE rb_handler) : m_rb_handler(rb_handler) {};
114
+ void sectionStart(wvWare::SharedPtr<const wvWare::Word97::SEP> sep);
115
+ RB_DELEGATE(sectionEnd, "section_end")
116
+ RB_DELEGATE(pageBreak, "page_break")
117
+ void paragraphStart(wvWare::SharedPtr<const wvWare::ParagraphProperties> pap);
118
+ RB_DELEGATE(paragraphEnd, "paragraph_end")
119
+ void runOfText(const wvWare::UString & text,
120
+ wvWare::SharedPtr<const wvWare::Word97::CHP> chp);
121
+ void pictureData( wvWare::SharedPtr<const wvWare::Word97::PICF> picf,
122
+ wvWare::U8 * buffer );
123
+ private:
124
+ VALUE m_rb_handler;
125
+ VALUE wrap_chp(wvWare::SharedPtr<const wvWare::Word97::CHP> chp);
126
+ };
127
+
128
+ } // extern "C"
129
+ #endif
@@ -0,0 +1,58 @@
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
+ #ifndef RWV2_PARSER_H
24
+ #define RWV2_PARSER_H
25
+
26
+ #include "ruby.h"
27
+
28
+ #include "wv2/parser.h"
29
+ #include "wv2/sharedptr.h"
30
+
31
+ #include "rwv2_handlers.h"
32
+
33
+ extern "C" {
34
+
35
+ typedef struct rwv2_parser {
36
+ wvWare::SharedPtr<wvWare::Parser> parser;
37
+ wvWare::InlineReplacementHandler * wv_inline_replacement_handler;
38
+ wvWare::SubDocumentHandler * wv_subdocument_handler;
39
+ wvWare::TableHandler * wv_table_handler;
40
+ wvWare::TextHandler * wv_text_handler;
41
+ VALUE rb_inline_replacement_handler;
42
+ VALUE rb_subdocument_handler;
43
+ VALUE rb_table_handler;
44
+ VALUE rb_text_handler;
45
+ } Rwv2Parser;
46
+
47
+ VALUE rwv2_parser_is_ok(VALUE self);
48
+ VALUE rwv2_parser_parse(VALUE self);
49
+ VALUE rwv2_parser_set_inline_replacement_handler(VALUE self, VALUE rb_handler);
50
+ VALUE rwv2_parser_set_subdocument_handler(VALUE self, VALUE rb_handler);
51
+ VALUE rwv2_parser_set_table_handler(VALUE self, VALUE rb_handler);
52
+ VALUE rwv2_parser_set_text_handler(VALUE self, VALUE rb_handler);
53
+ void rwv2_parser_mark(Rwv2Parser * stub);
54
+ void rwv2_parser_free(Rwv2Parser * stub);
55
+
56
+ } // extern "C"
57
+
58
+ #endif
@@ -0,0 +1,149 @@
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
+ #ifndef RWV2_CHARACTER_PROPERTIES_H
24
+ #define RWV2_CHARACTER_PROPERTIES_H
25
+
26
+ #include "wv2/word97_generated.h"
27
+ #include "wv2/paragraphproperties.h"
28
+
29
+ extern "C" {
30
+
31
+ typedef struct rwv2_sep {
32
+ wvWare::SharedPtr<const wvWare::Word97::SEP> wv_sep;
33
+ } Rwv2Sep;
34
+
35
+ VALUE rwv2_sep_break_code(VALUE self);
36
+ VALUE rwv2_sep_title_page(VALUE self);
37
+ VALUE rwv2_sep_page_number_format(VALUE self);
38
+ VALUE rwv2_sep_unlocked(VALUE self);
39
+ VALUE rwv2_sep_page_number_restart(VALUE self);
40
+ VALUE rwv2_sep_endnote(VALUE self);
41
+ VALUE rwv2_sep_line_numbering_code(VALUE self);
42
+ VALUE rwv2_sep_line_numbering_modulus(VALUE self);
43
+ VALUE rwv2_sep_columns(VALUE self);
44
+
45
+ void rwv2_sep_free(Rwv2Sep * stub);
46
+
47
+ typedef struct rwv2_pap {
48
+ wvWare::SharedPtr<const wvWare::ParagraphProperties> wv_pap;
49
+ } Rwv2Pap;
50
+
51
+ VALUE rwv2_pap_justify(VALUE self);
52
+ VALUE rwv2_pap_keep(VALUE self);
53
+ VALUE rwv2_pap_keep_follow(VALUE self);
54
+ VALUE rwv2_pap_page_break_before(VALUE self);
55
+ VALUE rwv2_pap_widow_control(VALUE self);
56
+ VALUE rwv2_pap_indent_right(VALUE self);
57
+ VALUE rwv2_pap_indent_left(VALUE self);
58
+ VALUE rwv2_pap_indent_first_line(VALUE self);
59
+ VALUE rwv2_pap_tab_descriptors(VALUE self);
60
+
61
+ typedef struct rwv2_chp {
62
+ wvWare::SharedPtr<const wvWare::Word97::CHP> wv_chp;
63
+ } Rwv2Chp;
64
+
65
+ VALUE rwv2_chp_bold(VALUE self);
66
+ VALUE rwv2_chp_italic(VALUE self);
67
+ VALUE rwv2_chp_rev_mark(VALUE self);
68
+ VALUE rwv2_chp_rev_mark_del(VALUE self);
69
+ VALUE rwv2_chp_outline(VALUE self);
70
+ VALUE rwv2_chp_small_caps(VALUE self);
71
+ VALUE rwv2_chp_caps(VALUE self);
72
+ VALUE rwv2_chp_special_char(VALUE self);
73
+ VALUE rwv2_chp_strikethrough(VALUE self);
74
+ VALUE rwv2_chp_shadow(VALUE self);
75
+ VALUE rwv2_chp_lowercase(VALUE self);
76
+ VALUE rwv2_chp_emboss(VALUE self);
77
+ VALUE rwv2_chp_imprint(VALUE self);
78
+ VALUE rwv2_chp_double_strikethrough(VALUE self);
79
+ VALUE rwv2_chp_position(VALUE self);
80
+ VALUE rwv2_chp_underline(VALUE self);
81
+ VALUE rwv2_chp_scale(VALUE self);
82
+ VALUE rwv2_chp_font_hps(VALUE self);
83
+
84
+ void rwv2_chp_free(Rwv2Chp * stub);
85
+
86
+ typedef struct rwv2_tap {
87
+ wvWare::SharedPtr<const wvWare::Word97::TAP> wv_tap;
88
+ } Rwv2Tap;
89
+
90
+ VALUE rwv2_tap_justify(VALUE self);
91
+ VALUE rwv2_tap_gap_half(VALUE self);
92
+ VALUE rwv2_tap_row_height(VALUE self);
93
+ VALUE rwv2_tap_cant_split(VALUE self);
94
+ VALUE rwv2_tap_table_header(VALUE self);
95
+ VALUE rwv2_tap_row_cells(VALUE self);
96
+ VALUE rwv2_tap_cell_boundaries(VALUE self);
97
+ VALUE rwv2_tap_cell_descriptors(VALUE self);
98
+
99
+ void rwv2_tap_free(Rwv2Tap * stub);
100
+
101
+ typedef struct rwv2_tc {
102
+ wvWare::Word97::TC * wv_tc;
103
+ } Rwv2Tc;
104
+
105
+ VALUE rwv2_tc_first_merged(VALUE self);
106
+ VALUE rwv2_tc_merged(VALUE self);
107
+ VALUE rwv2_tc_vertical(VALUE self);
108
+ VALUE rwv2_tc_backward(VALUE self);
109
+ VALUE rwv2_tc_rotate_font(VALUE self);
110
+ VALUE rwv2_tc_vertical_merged(VALUE self);
111
+ VALUE rwv2_tc_vertical_restart(VALUE self);
112
+ VALUE rwv2_tc_vertical_align(VALUE self);
113
+
114
+ void rwv2_tc_free(Rwv2Tc * stub);
115
+
116
+ typedef struct rwv2_tab {
117
+ wvWare::Word97::TabDescriptor * wv_tab;
118
+ } Rwv2Tab;
119
+
120
+ VALUE rwv2_tab_position(VALUE self);
121
+ VALUE rwv2_tab_justify(VALUE self);
122
+
123
+ void rwv2_tab_free(Rwv2Tab * stub);
124
+
125
+ typedef struct rwv2_picf {
126
+ wvWare::SharedPtr<const wvWare::Word97::PICF> wv_picf;
127
+ VALUE rb_blob;
128
+ } Rwv2Picf;
129
+
130
+ VALUE rwv2_picf_blob(VALUE self);
131
+ VALUE rwv2_picf_mapping_mode(VALUE self);
132
+ VALUE rwv2_picf_display_height(VALUE self);
133
+ VALUE rwv2_picf_display_width(VALUE self);
134
+ VALUE rwv2_picf_scaling_horizontal(VALUE self);
135
+ VALUE rwv2_picf_scaling_vertical(VALUE self);
136
+ VALUE rwv2_picf_crop_left(VALUE self);
137
+ VALUE rwv2_picf_crop_top(VALUE self);
138
+ VALUE rwv2_picf_crop_right(VALUE self);
139
+ VALUE rwv2_picf_crop_bottom(VALUE self);
140
+ VALUE rwv2_picf_is_bitmap(VALUE self);
141
+ VALUE rwv2_picf_is_active_ole(VALUE self);
142
+
143
+ void rwv2_picf_free(Rwv2Picf * self);
144
+ void rwv2_picf_mark(Rwv2Picf * self);
145
+
146
+ } // extern "C"
147
+
148
+
149
+ #endif