swfmill 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.document +5 -0
  2. data/.gitignore +23 -0
  3. data/.swfmill +240 -0
  4. data/LICENSE +340 -0
  5. data/README.rdoc +37 -0
  6. data/Rakefile +59 -0
  7. data/VERSION +1 -0
  8. data/ext/.gitignore +5 -0
  9. data/ext/extconf.rb +86 -0
  10. data/ext/swfmill/.gitignore +27 -0
  11. data/ext/swfmill/AUTHORS +9 -0
  12. data/ext/swfmill/COPYING +340 -0
  13. data/ext/swfmill/Makefile.am +14 -0
  14. data/ext/swfmill/Makefile.in +635 -0
  15. data/ext/swfmill/NEWS +189 -0
  16. data/ext/swfmill/README +170 -0
  17. data/ext/swfmill/TODO +33 -0
  18. data/ext/swfmill/aclocal.m4 +7712 -0
  19. data/ext/swfmill/autogen.sh +7 -0
  20. data/ext/swfmill/compile +142 -0
  21. data/ext/swfmill/config.guess +1516 -0
  22. data/ext/swfmill/config.sub +1626 -0
  23. data/ext/swfmill/configure +21868 -0
  24. data/ext/swfmill/configure.ac +55 -0
  25. data/ext/swfmill/depcomp +589 -0
  26. data/ext/swfmill/install-sh +519 -0
  27. data/ext/swfmill/ltmain.sh +6964 -0
  28. data/ext/swfmill/missing +367 -0
  29. data/ext/swfmill/src/Geom.cpp +107 -0
  30. data/ext/swfmill/src/Geom.h +100 -0
  31. data/ext/swfmill/src/Makefile.am +86 -0
  32. data/ext/swfmill/src/Makefile.in +1025 -0
  33. data/ext/swfmill/src/SWF.h +11941 -0
  34. data/ext/swfmill/src/SWFAction.cpp +41 -0
  35. data/ext/swfmill/src/SWFAction.h +19 -0
  36. data/ext/swfmill/src/SWFBasic.h +7 -0
  37. data/ext/swfmill/src/SWFFile.cpp +406 -0
  38. data/ext/swfmill/src/SWFFile.h +34 -0
  39. data/ext/swfmill/src/SWFFilter.cpp +25 -0
  40. data/ext/swfmill/src/SWFFilter.h +15 -0
  41. data/ext/swfmill/src/SWFGlyphList.cpp +262 -0
  42. data/ext/swfmill/src/SWFGlyphList.h +34 -0
  43. data/ext/swfmill/src/SWFIdItem.h +85 -0
  44. data/ext/swfmill/src/SWFIdItems.h +16 -0
  45. data/ext/swfmill/src/SWFItem.cpp +235 -0
  46. data/ext/swfmill/src/SWFItem.h +60 -0
  47. data/ext/swfmill/src/SWFList.h +179 -0
  48. data/ext/swfmill/src/SWFReader.cpp +352 -0
  49. data/ext/swfmill/src/SWFReader.h +73 -0
  50. data/ext/swfmill/src/SWFShapeItem.cpp +220 -0
  51. data/ext/swfmill/src/SWFShapeItem.h +45 -0
  52. data/ext/swfmill/src/SWFShapeMaker.cpp +401 -0
  53. data/ext/swfmill/src/SWFShapeMaker.h +128 -0
  54. data/ext/swfmill/src/SWFTag.cpp +49 -0
  55. data/ext/swfmill/src/SWFTag.h +20 -0
  56. data/ext/swfmill/src/SWFTrait.cpp +35 -0
  57. data/ext/swfmill/src/SWFTrait.h +22 -0
  58. data/ext/swfmill/src/SWFWriter.cpp +312 -0
  59. data/ext/swfmill/src/SWFWriter.h +84 -0
  60. data/ext/swfmill/src/base64.c +110 -0
  61. data/ext/swfmill/src/base64.h +15 -0
  62. data/ext/swfmill/src/codegen/Makefile.am +15 -0
  63. data/ext/swfmill/src/codegen/Makefile.in +346 -0
  64. data/ext/swfmill/src/codegen/basic.xsl +45 -0
  65. data/ext/swfmill/src/codegen/basics.xsl +235 -0
  66. data/ext/swfmill/src/codegen/dumper.xsl +109 -0
  67. data/ext/swfmill/src/codegen/header.xsl +131 -0
  68. data/ext/swfmill/src/codegen/mk.xsl +26 -0
  69. data/ext/swfmill/src/codegen/parser.xsl +196 -0
  70. data/ext/swfmill/src/codegen/parsexml.xsl +312 -0
  71. data/ext/swfmill/src/codegen/size.xsl +189 -0
  72. data/ext/swfmill/src/codegen/source.xml +2197 -0
  73. data/ext/swfmill/src/codegen/writer.xsl +190 -0
  74. data/ext/swfmill/src/codegen/writexml.xsl +138 -0
  75. data/ext/swfmill/src/swfmill.cpp +482 -0
  76. data/ext/swfmill/src/swft/Makefile.am +55 -0
  77. data/ext/swfmill/src/swft/Makefile.in +717 -0
  78. data/ext/swfmill/src/swft/Parser.cpp +76 -0
  79. data/ext/swfmill/src/swft/Parser.h +37 -0
  80. data/ext/swfmill/src/swft/SVGAttributeParser.cpp +78 -0
  81. data/ext/swfmill/src/swft/SVGAttributeParser.h +35 -0
  82. data/ext/swfmill/src/swft/SVGColor.cpp +116 -0
  83. data/ext/swfmill/src/swft/SVGColor.h +37 -0
  84. data/ext/swfmill/src/swft/SVGColors.h +167 -0
  85. data/ext/swfmill/src/swft/SVGGradient.cpp +258 -0
  86. data/ext/swfmill/src/swft/SVGGradient.h +81 -0
  87. data/ext/swfmill/src/swft/SVGPathParser.cpp +155 -0
  88. data/ext/swfmill/src/swft/SVGPathParser.h +126 -0
  89. data/ext/swfmill/src/swft/SVGPointsParser.cpp +51 -0
  90. data/ext/swfmill/src/swft/SVGPointsParser.h +25 -0
  91. data/ext/swfmill/src/swft/SVGStyle.cpp +181 -0
  92. data/ext/swfmill/src/swft/SVGStyle.h +80 -0
  93. data/ext/swfmill/src/swft/SVGTransformParser.cpp +72 -0
  94. data/ext/swfmill/src/swft/SVGTransformParser.h +32 -0
  95. data/ext/swfmill/src/swft/readpng.c +305 -0
  96. data/ext/swfmill/src/swft/readpng.h +92 -0
  97. data/ext/swfmill/src/swft/swft.cpp +251 -0
  98. data/ext/swfmill/src/swft/swft.h +64 -0
  99. data/ext/swfmill/src/swft/swft_document.cpp +57 -0
  100. data/ext/swfmill/src/swft/swft_import.cpp +38 -0
  101. data/ext/swfmill/src/swft/swft_import_binary.cpp +82 -0
  102. data/ext/swfmill/src/swft/swft_import_jpeg.cpp +255 -0
  103. data/ext/swfmill/src/swft/swft_import_mp3.cpp +268 -0
  104. data/ext/swfmill/src/swft/swft_import_png.cpp +231 -0
  105. data/ext/swfmill/src/swft/swft_import_ttf.cpp +519 -0
  106. data/ext/swfmill/src/swft/swft_import_wav.cpp +255 -0
  107. data/ext/swfmill/src/swft/swft_path.cpp +178 -0
  108. data/ext/swfmill/src/xslt/Makefile.am +51 -0
  109. data/ext/swfmill/src/xslt/Makefile.in +536 -0
  110. data/ext/swfmill/src/xslt/README +19 -0
  111. data/ext/swfmill/src/xslt/assemble.xsl +38 -0
  112. data/ext/swfmill/src/xslt/simple-deprecated.xslt +62 -0
  113. data/ext/swfmill/src/xslt/simple-elements.xslt +627 -0
  114. data/ext/swfmill/src/xslt/simple-import.xslt +565 -0
  115. data/ext/swfmill/src/xslt/simple-svg.xslt +383 -0
  116. data/ext/swfmill/src/xslt/simple-tools.xslt +255 -0
  117. data/ext/swfmill/src/xslt/simple.cpp +1686 -0
  118. data/ext/swfmill/src/xslt/simple.xml +7 -0
  119. data/ext/swfmill/src/xslt/xslt.h +7 -0
  120. data/ext/swfmill/test/Makefile.am +1 -0
  121. data/ext/swfmill/test/Makefile.in +490 -0
  122. data/ext/swfmill/test/xml/Makefile.am +20 -0
  123. data/ext/swfmill/test/xml/Makefile.in +353 -0
  124. data/ext/swfmill/test/xml/test-xml +21 -0
  125. data/ext/swfmill_ext.cc +375 -0
  126. data/lib/swfmill.rb +30 -0
  127. data/spec/data/swfmill-banner1.swf +0 -0
  128. data/spec/spec.opts +1 -0
  129. data/spec/spec_helper.rb +14 -0
  130. data/spec/swfmill_spec.rb +125 -0
  131. metadata +206 -0
@@ -0,0 +1,255 @@
1
+ #include <libxslt/extensions.h>
2
+ #include <libxslt/xsltutils.h>
3
+ #include <libxslt/variables.h>
4
+ #include <libxml/xpathInternals.h>
5
+ #include "swft.h"
6
+ #include <sys/types.h>
7
+ #include <sys/stat.h>
8
+ #include <cstring>
9
+
10
+ #define TMP_STRLEN 0xff
11
+
12
+ #define ERROR_NO_WAV -1
13
+ #define ERROR_WRONG_SAMPLING_RATE -2
14
+
15
+
16
+ struct WaveInfo {
17
+ int samplingRate;
18
+ int samples;
19
+ int flashSamplingRateFlag;
20
+ int stereo;
21
+ int is16bit;
22
+ int wave_data_size;
23
+ const char *wave_data_ptr;
24
+ bool valid;
25
+ bool wrongSamplingRate;
26
+ };
27
+
28
+ typedef enum {
29
+ WAVE_INVALID,
30
+ WAVE_PCM = 1,
31
+ } WaveFormatCode;
32
+
33
+
34
+ void getWaveInfo( WaveInfo& info, char* data, int size ) {
35
+ info.stereo = 0;
36
+ info.wrongSamplingRate = false;
37
+ int pos = 0;
38
+
39
+ info.valid = false;
40
+
41
+ const char *ptr = data;
42
+
43
+ if (strncmp(ptr, "RIFF", 4) != 0) {
44
+ fprintf(stderr, "Error: RIFF header missing\n");
45
+ return;
46
+ }
47
+
48
+ ptr += 4;
49
+
50
+ if ( *((unsigned int *)ptr) + 8 != size) {
51
+ fprintf(stderr, "Error: File size differs from that described in RIFF header\n");
52
+ return;
53
+ }
54
+
55
+ ptr += 4;
56
+
57
+ if (strncmp(ptr, "WAVE", 4) != 0) {
58
+ fprintf(stderr, "Error: Expected WAVE chunk\n");
59
+ return;
60
+ }
61
+
62
+ ptr += 4;
63
+
64
+ if (strncmp(ptr, "fmt ", 4) != 0) {
65
+ fprintf(stderr, "Error: Expected fmt_ subchunk\n");
66
+ return;
67
+ }
68
+
69
+ ptr += 4;
70
+
71
+ /* Look ahead a bit */
72
+ unsigned short format_code = *((unsigned short *)(ptr+4));
73
+ if (format_code != WAVE_PCM) {
74
+ fprintf(stderr, "Error: Format code in WAVE file is not PCM (%d)\n", format_code);
75
+ }
76
+
77
+ if ( *((unsigned int *)ptr) != 16) {
78
+ fprintf(stderr, "Error: fmt_ subchunk size != 16. Is format code PCM?\n");
79
+ return;
80
+ }
81
+
82
+ if (format_code != WAVE_PCM) {
83
+ return;
84
+ }
85
+
86
+
87
+ /* Skip format code, already checked that */
88
+ ptr += 6;
89
+
90
+ unsigned short num_channels = *((unsigned short *)ptr);
91
+ if (num_channels < 1 || num_channels > 2) {
92
+ fprintf(stderr, "Error: Channels should be 1 or 2 (is %d)\n", num_channels);
93
+ return;
94
+ }
95
+
96
+ info.stereo = num_channels == 2;
97
+
98
+ ptr += 2;
99
+
100
+ unsigned int sample_rate = *((unsigned int *)ptr);
101
+ info.samplingRate = sample_rate;
102
+ switch (sample_rate) {
103
+ case 5512:
104
+ info.flashSamplingRateFlag = 0;
105
+ break;
106
+ case 11025:
107
+ info.flashSamplingRateFlag = 1;
108
+ break;
109
+ case 22050:
110
+ info.flashSamplingRateFlag = 2;
111
+ break;
112
+ case 44100:
113
+ info.flashSamplingRateFlag = 3;
114
+ break;
115
+ default:
116
+ fprintf(stderr, "Invalid sampling rate, please use either 5.5k, 11k, 22k or 44k (is: %d Hz)\n", sample_rate);
117
+ info.wrongSamplingRate = true;
118
+ return;
119
+ }
120
+
121
+ /* Skip some derived fields */
122
+ ptr += 10;
123
+
124
+ unsigned short bits_per_sample = *((unsigned short *)ptr);
125
+ if (bits_per_sample != 8 && bits_per_sample != 16) {
126
+ fprintf(stderr, "Error: Bit per sample should be either 8 or 16 (is: %d)\n", bits_per_sample);
127
+ return;
128
+ }
129
+ info.is16bit = bits_per_sample == 16;
130
+
131
+ ptr += 2;
132
+
133
+ if (strncmp(ptr, "data", 4) != 0) {
134
+ fprintf(stderr, "Error: Expected data_ subchunk\n");
135
+ return;
136
+ }
137
+
138
+ ptr += 4;
139
+
140
+ info.wave_data_size = *((unsigned int*)ptr);
141
+
142
+ info.samples = info.wave_data_size / num_channels / (info.is16bit ? 2 : 1);
143
+
144
+ info.wave_data_ptr = ptr + 4;
145
+
146
+ info.valid = true;
147
+ }
148
+
149
+ void swft_import_wav( xmlXPathParserContextPtr ctx, int nargs ) {
150
+ xsltTransformContextPtr tctx;
151
+ xmlChar *filename;
152
+ xsltDocumentPtr xsltdoc;
153
+ xmlDocPtr doc = NULL;
154
+ xmlNodePtr node;
155
+ xmlXPathObjectPtr obj;
156
+ char tmp[TMP_STRLEN];
157
+ //data variables
158
+ unsigned char *data = NULL;
159
+ int size;
160
+ struct stat filestat;
161
+
162
+ xmlXPathStringFunction(ctx, 1);
163
+ if (ctx->value->type != XPATH_STRING) {
164
+ xsltTransformError(xsltXPathGetTransformContext(ctx), NULL, NULL,
165
+ "swft:import-wav() : invalid arg expecting a string\n");
166
+ ctx->error = XPATH_INVALID_TYPE;
167
+ return;
168
+ }
169
+ obj = valuePop(ctx);
170
+ if (obj->stringval == NULL) {
171
+ valuePush(ctx, xmlXPathNewNodeSet(NULL));
172
+ return;
173
+ }
174
+
175
+ tctx = xsltXPathGetTransformContext(ctx);
176
+
177
+ filename = obj->stringval;
178
+
179
+ bool quiet = true;
180
+ xmlXPathObjectPtr quietObj = xsltVariableLookup( tctx, (const xmlChar*)"quiet", NULL );
181
+ if( quietObj && quietObj->stringval ) { quiet = !strcmp("true",(const char*)quietObj->stringval ); };
182
+
183
+
184
+ FILE *fp = fopen( (const char *)filename, "rb" );
185
+ if( !fp ) {
186
+ xsltTransformError(xsltXPathGetTransformContext(ctx), NULL, NULL,
187
+ "swft:import-wav() : failed to read file '%s'\n", (const char *)filename);
188
+ valuePush(ctx, xmlXPathNewNodeSet(NULL));
189
+ return;
190
+ }
191
+
192
+ doc = xmlNewDoc( (const xmlChar *)"1.0");
193
+ doc->xmlRootNode = xmlNewDocNode( doc, NULL, (const xmlChar *)"wav", NULL );
194
+ node = doc->xmlRootNode;
195
+
196
+ swft_addFileName( node, (const char *)filename );
197
+
198
+ // get file size
199
+ if( stat( (const char *)filename, &filestat ) ) {
200
+ goto fail;
201
+ }
202
+
203
+ size = filestat.st_size;
204
+ data = new unsigned char[size];
205
+
206
+ // read data
207
+ if( fread( data, 1, size, fp ) != size ) {
208
+ fprintf(stderr,"WARNING: could not read enough (%i) bytes from WAVE file %s\n", size, filename );
209
+ goto fail;
210
+ }
211
+
212
+ if( size == 0 ) {
213
+ fprintf(stderr,"WARNING: WAVE file %s is empty\n", filename );
214
+ goto fail;
215
+ }
216
+
217
+ WaveInfo info;
218
+ getWaveInfo(info, (char *)data, size);
219
+
220
+ if( !info.valid ) {
221
+ fprintf(stderr,"WARNING: this file is not a valid WAVE file: %s\n", filename );
222
+ goto fail;
223
+ }
224
+
225
+ if( info.wrongSamplingRate ) {
226
+ fprintf(stderr,"WARNING: WAVE file %s has a wrong sampling rate\n", filename );
227
+ goto fail;
228
+ }
229
+
230
+ xmlSetProp( node, (const xmlChar *)"format", (const xmlChar *)"3" ); // uncompressed little-endian
231
+
232
+ snprintf(tmp,TMP_STRLEN,"%i", info.flashSamplingRateFlag);
233
+ xmlSetProp( node, (const xmlChar *)"rate", (const xmlChar *)&tmp );
234
+
235
+ snprintf(tmp,TMP_STRLEN,"%i", info.is16bit);
236
+ xmlSetProp( node, (const xmlChar *)"is16bit", (const xmlChar *)&tmp );
237
+
238
+ snprintf(tmp,TMP_STRLEN,"%i", info.stereo);
239
+ xmlSetProp( node, (const xmlChar *)"stereo", (const xmlChar *)&tmp );
240
+
241
+ snprintf(tmp,TMP_STRLEN,"%i", info.samples);
242
+ xmlSetProp( node, (const xmlChar *)"samples", (const xmlChar *)&tmp );
243
+
244
+ if( !quiet ) {
245
+ fprintf(stderr, "Importing WAVE file: '%s'\n", filename);
246
+ }
247
+
248
+ swft_addData( node, (char*)info.wave_data_ptr, info.wave_data_size );
249
+ valuePush( ctx, xmlXPathNewNodeSet( (xmlNodePtr)doc ) );
250
+
251
+ fail:
252
+ if( fp ) fclose(fp);
253
+ if( data ) delete data;
254
+ }
255
+
@@ -0,0 +1,178 @@
1
+ #include "swft.h"
2
+ #include "SVGPathParser.h"
3
+ #include "SVGTransformParser.h"
4
+ #include "SVGAttributeParser.h"
5
+ #include "SVGPointsParser.h"
6
+ #include "SVGStyle.h"
7
+ #include <libxml/xpathInternals.h>
8
+ #include <libxslt/xsltutils.h>
9
+ #include <libxslt/extensions.h>
10
+
11
+ using namespace SWF;
12
+
13
+ /*
14
+ Create a complete DefineShape3 element.
15
+ syntax: swft:path( <node> , <shapeid> , <movie-version> )
16
+ */
17
+ void swft_path(xmlXPathParserContextPtr ctx, int nargs) {
18
+ xmlChar *styleString, *idString, *pathString;
19
+ xmlDocPtr doc;
20
+ xmlNodePtr node;
21
+ xmlNodeSetPtr nodeSet;
22
+ double movieVersion;
23
+
24
+ if(nargs != 3) {
25
+ xmlXPathSetArityError(ctx);
26
+ return;
27
+ }
28
+
29
+ movieVersion = xmlXPathPopNumber(ctx);
30
+ idString = xmlXPathPopString(ctx);
31
+ nodeSet = xmlXPathPopNodeSet(ctx);
32
+
33
+ if(nodeSet == NULL || nodeSet->nodeNr != 1) {
34
+ xmlXPathSetTypeError(ctx);
35
+ return;
36
+ }
37
+
38
+ node = nodeSet->nodeTab[0];
39
+
40
+ swft_ctx *c = (swft_ctx*)xsltGetExtData(xsltXPathGetTransformContext(ctx), SWFT_NAMESPACE);
41
+ SVGStyle style;
42
+ if(c->styles.size() > 0) {
43
+ style = c->styles.top();
44
+ }
45
+
46
+ style.parseNode(node, c->gradients);
47
+
48
+ if(!style.hasStyle()) {
49
+ style.setFillColor("#000");
50
+ }
51
+
52
+ Shape shape;
53
+ int xOffset = 0, yOffset = 0;
54
+ ShapeMaker shaper(shape.getedges(), 20, 20, xOffset, yOffset);
55
+ shaper.setStyle(style.hasFill() ? 1 : -1, -1, style.hasStroke() ? 1 : -1);
56
+
57
+ AttributeParser attribs;
58
+ attribs.parseNode(node);
59
+
60
+ if(!xmlStrcmp(node->name, (const xmlChar *)"path")) {
61
+ const char* pathString = attribs["d"];
62
+ if(pathString) {
63
+ PathParser parser(&shaper);
64
+ parser.parse(pathString);
65
+ }
66
+ } else if(!xmlStrcmp(node->name, (const xmlChar *)"rect")) {
67
+ double w = attribs.getDouble("width");
68
+ double h = attribs.getDouble("height");
69
+ if(w > 0 && h > 0) {
70
+ double rx = attribs.getDouble("rx");
71
+ double ry = attribs.getDouble("ry");
72
+
73
+ if(attribs["rx"] == NULL && attribs["ry"] == NULL) {
74
+ rx = ry = 0;
75
+ } else if(attribs["rx"] == NULL && attribs["ry"] != NULL) {
76
+ rx = ry;
77
+ } else if(attribs["rx"] != NULL && attribs["ry"] == NULL) {
78
+ ry = rx;
79
+ }
80
+
81
+ if(rx > w / 2) rx = w / 2;
82
+ if(ry > h / 2) ry = h / 2;
83
+
84
+ shaper.rect( attribs.getDouble("x"), attribs.getDouble("y"), w, h, rx, ry);
85
+ }
86
+ } else if(!xmlStrcmp(node->name, (const xmlChar *)"circle")) {
87
+ double r = attribs.getDouble("r");
88
+ if(r > 0)
89
+ shaper.ellipse(attribs.getDouble("cx"), attribs.getDouble("cy"), r, r);
90
+ } else if(!xmlStrcmp(node->name, (const xmlChar *)"ellipse")) {
91
+ double rx = attribs.getDouble("rx");
92
+ double ry = attribs.getDouble("ry");
93
+ if(rx > 0 && ry > 0)
94
+ shaper.ellipse(attribs.getDouble("cx"), attribs.getDouble("cy"), rx, ry);
95
+ } else if(!xmlStrcmp(node->name, (const xmlChar *)"line")) {
96
+ shaper.setup(attribs.getDouble("x1"), attribs.getDouble("y1"));
97
+ shaper.lineTo(attribs.getDouble("x2"), attribs.getDouble("y2"));
98
+ } else if(!xmlStrcmp(node->name, (const xmlChar *)"polyline") ||
99
+ !xmlStrcmp(node->name, (const xmlChar *)"polygon")) {
100
+ PointsParser parser;
101
+ parser.parse(attribs["points"]);
102
+
103
+ if(parser.getPointCount() >= 2) {
104
+ Point point, firstPoint;
105
+
106
+ firstPoint = parser.getPoint();
107
+ shaper.setup(firstPoint.x, firstPoint.y);
108
+
109
+ int pointCount = parser.getPointCount();
110
+ for(int i = 0; i < pointCount; i++) {
111
+ point = parser.getPoint();
112
+ shaper.lineTo(point.x, point.y);
113
+ }
114
+
115
+ if(!xmlStrcmp(node->name, (const xmlChar *)"polyline")) {
116
+ shaper.close(false);
117
+ } else {
118
+ shaper.close(true);
119
+ }
120
+ }
121
+ }
122
+
123
+ xmlNodePtr shapeNode, styleNode;
124
+
125
+ // make the shape xml
126
+ doc = xmlNewDoc( (const xmlChar *)"1.0");
127
+
128
+ if(movieVersion > 7) {
129
+ node = shapeNode = doc->xmlRootNode = xmlNewDocNode( doc, NULL, (const xmlChar *)"DefineShape5", NULL );
130
+ } else {
131
+ node = shapeNode = doc->xmlRootNode = xmlNewDocNode( doc, NULL, (const xmlChar *)"DefineShape3", NULL );
132
+ }
133
+
134
+ xmlSetProp( node, (const xmlChar*)"objectID", idString );
135
+
136
+ // bounds
137
+ shaper.boundsWriteXML(shapeNode, (style.hasStroke() ? style.getStrokeWidth() / 2 : 0));
138
+
139
+ // stroke bounds
140
+ if(movieVersion > 7)
141
+ shaper.boundsWriteXML(shapeNode);
142
+
143
+ // styles
144
+ node = xmlNewChild(shapeNode, NULL, (const xmlChar *)"styles", NULL);
145
+ style.setBounds(shaper.getBounds());
146
+ style.writeXML(node, movieVersion);
147
+
148
+ // the shape itself
149
+ shaper.finish();
150
+ node = xmlNewChild(shapeNode, NULL, (const xmlChar *)"shapes", NULL);
151
+
152
+ Context swfctx;
153
+ shape.writeXML( node, &swfctx );
154
+
155
+ valuePush( ctx, xmlXPathNewNodeSet( (xmlNodePtr)doc ) );
156
+ return;
157
+ }
158
+
159
+ void swft_transform( xmlXPathParserContextPtr ctx, int nargs ) {
160
+ if(nargs != 1) {
161
+ xmlXPathSetArityError(ctx);
162
+ return;
163
+ }
164
+
165
+ xmlChar *transform = xmlXPathPopString(ctx);
166
+ if(xmlXPathCheckError(ctx) || (transform == NULL)) {
167
+ return;
168
+ }
169
+
170
+ TransformParser transformParser;
171
+ transformParser.parse((char *)transform);
172
+
173
+ xmlDocPtr doc;
174
+ doc = xmlNewDoc( (const xmlChar *)"1.0");
175
+ doc->xmlRootNode = xmlNewDocNode( doc, NULL, (const xmlChar *)"Transform", NULL );
176
+ transformParser.getMatrix().setXMLProps(doc->xmlRootNode);
177
+ valuePush( ctx, xmlXPathNewNodeSet( (xmlNodePtr)doc ) );
178
+ }
@@ -0,0 +1,51 @@
1
+
2
+ NULL =
3
+ MAINTAINERCLEANFILES = Makefile.in simple.xsl
4
+
5
+ ALL_XSLT = \
6
+ simple-tools.xslt \
7
+ simple-elements.xslt \
8
+ simple-import.xslt \
9
+ simple-deprecated.xslt \
10
+ simple-svg.xslt \
11
+ $(NULL)
12
+
13
+ EXTRA_DIST = \
14
+ assemble.xsl \
15
+ simple.xml \
16
+ $(ALL_XSLT) \
17
+ $(NULL)
18
+
19
+ noinst_HEADERS = \
20
+ xslt.h \
21
+ $(NULL)
22
+
23
+ lib_LTLIBRARIES = libswfmillxslt.la
24
+
25
+ libswfmillxslt_la_CFLAGS =
26
+ libswfmillxslt_la_CXXFLAGS = $(libswfmillxslt_la_CFLAGS)
27
+ libswfmillxslt_la_LIBADD =
28
+
29
+ BUILT_SOURCES = \
30
+ simple.cpp \
31
+ $(NULL)
32
+
33
+ #CLEAN_FILES = $(BUILT_SOURCES)
34
+
35
+ NAMESPACES = xmlns:swft=\"http:\/\/subsignal.org\/swfml\/swft\" \
36
+ xmlns:str=\"http:\/\/exslt.org\/strings\" \
37
+ xmlns:math=\"http:\/\/exslt.org\/math\"
38
+
39
+ SUFFIXES = .cpp .xml
40
+
41
+ .xml.cpp: assemble.xsl $(ALL_XSLT)
42
+ xsltproc $(srcdir)/assemble.xsl $< > $(@:.cpp=.xsl)
43
+ echo "#include \"xslt.h\"" > $@
44
+ echo "const char *xslt_$* = " >> $@
45
+ sed -e "s/namespaces=\\\"hack\\\"/$(NAMESPACES)/" -e "s/\"/\\\\\"/g" -e "s/\(.*\)/\"\1\\\\n\"/g" $(@:.cpp=.xsl) >> $@
46
+ echo ";" >> $@
47
+
48
+ libswfmillxslt_la_SOURCES = \
49
+ $(BUILT_SOURCES)
50
+ $(NULL)
51
+