summaryrefslogtreecommitdiff
path: root/libmspub/libmspub-0.0.1.patch
blob: a28169b7bcdd480b8d212f83dcf57c72a282d279 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
--- misc/libmspub-0.0.1/src/lib/MSPUBCollector.cpp	2012-07-10 08:13:15.000000000 +0200
+++ misc/build/libmspub-0.0.1/src/lib/MSPUBCollector.cpp	2012-07-12 01:29:28.154982030 +0200
@@ -28,6 +28,7 @@
  * instead of those above.
  */
 
+#include <math.h>
 #include "MSPUBCollector.h"
 #include "ShapeGroupPainter.h"
 #include "libmspub_utils.h"
@@ -35,6 +36,10 @@
 #include "MSPUBTypes.h"
 #include "PolygonUtils.h"
 
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 libmspub::MSPUBCollector::MSPUBCollector(libwpg::WPGPaintInterface *painter) :
   m_painter(painter), m_contentChunkReferences(), m_width(0), m_height(0),
   m_widthSet(false), m_heightSet(false),
@@ -364,11 +369,11 @@
   case 7:
     return sqrt(valOne * valTwo * valThree);
   case 8:
-    return atan2(valTwo, valOne) / (PI / 180);
+    return atan2(valTwo, valOne) / (M_PI / 180);
   case 9:
-    return valOne * sin(valTwo * (PI / 180) );
+    return valOne * sin(valTwo * (M_PI / 180) );
   case 10:
-    return valOne * cos(valTwo * (PI / 180) );
+    return valOne * cos(valTwo * (M_PI / 180) );
   case 11:
     return valOne * cos(atan2(valThree, valTwo));
   case 12:
@@ -382,9 +387,9 @@
   case 0x80:
     return sqrt(valThree * valThree - valOne * valOne);
   case 0x81:
-    return (cos(valThree * (PI / 180)) * (valOne - 10800) + sin(valThree * (PI / 180)) * (valTwo - 10800)) + 10800;
+    return (cos(valThree * (M_PI / 180)) * (valOne - 10800) + sin(valThree * (M_PI / 180)) * (valTwo - 10800)) + 10800;
   case 0x82:
-    return -(sin(valThree * (PI / 180)) * (valOne - 10800) - cos(valThree * (PI / 180)) * (valTwo - 10800)) + 10800;
+    return -(sin(valThree * (M_PI / 180)) * (valOne - 10800) - cos(valThree * (M_PI / 180)) * (valTwo - 10800)) + 10800;
   default:
     return 0;
   }
@@ -623,10 +628,10 @@
     unsigned seqNum = i->first;
     double *ptr_rotation = getIfExists(m_shapeRotationsBySeqNum, seqNum);
     VectorTransformation2D rot = ptr_rotation ? VectorTransformation2D::fromCounterRadians((*ptr_rotation) * M_PI / 180.)
-                                 : IDENTITY_TRANSFORMATION;
+                                 : VectorTransformation2D();
     std::pair<bool, bool> *ptr_flips = getIfExists(m_shapeFlipsBySeqNum, seqNum);
     VectorTransformation2D flips = ptr_flips ? VectorTransformation2D::fromFlips(ptr_flips->second, ptr_flips->first) :
-                                   IDENTITY_TRANSFORMATION;
+                                   VectorTransformation2D();
     group.m_transform = rot * flips;
     Coordinate *ptr_coords = getIfExists(m_shapeCoordinatesBySeqNum, seqNum);
     if (ptr_coords)
@@ -655,9 +660,9 @@
       shape->m_coordinatesRotated90 = true;
     }
     VectorTransformation2D rot = ptr_rotation ? VectorTransformation2D::fromCounterRadians(
-                                   (*ptr_rotation) * M_PI / 180.) : IDENTITY_TRANSFORMATION;
+                                   (*ptr_rotation) * M_PI / 180.) : VectorTransformation2D();
     std::pair<bool, bool> *ptr_flips = getIfExists(m_shapeFlipsBySeqNum, seqNum);
-    VectorTransformation2D flips = ptr_flips ? VectorTransformation2D::fromFlips(ptr_flips->second, ptr_flips->first) : IDENTITY_TRANSFORMATION;
+    VectorTransformation2D flips = ptr_flips ? VectorTransformation2D::fromFlips(ptr_flips->second, ptr_flips->first) : VectorTransformation2D();
     shape->m_transform = rot * flips;
     ShapeType *type = getIfExists(m_shapeTypesBySeqNum, seqNum);
     if (type)
--- misc/libmspub-0.0.1/src/lib/MSPUBCollector.h	2012-07-10 08:13:15.000000000 +0200
+++ misc/build/libmspub-0.0.1/src/lib/MSPUBCollector.h	2012-07-12 01:29:14.047323447 +0200
@@ -36,7 +36,6 @@
 #include <set>
 #include <string>
 #include <algorithm>
-#include <cmath>
 
 #include <boost/ptr_container/ptr_map.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
@@ -55,8 +54,6 @@
 #include "ShapeGroupPainter.h"
 #include "ShapeGroup.h"
 
-#define PI 3.14159265
-
 namespace libmspub
 {
 class MSPUBCollector
--- misc/libmspub-0.0.1/src/lib/PolygonUtils.cpp	2012-07-10 08:13:15.000000000 +0200
+++ misc/build/libmspub-0.0.1/src/lib/PolygonUtils.cpp	2012-07-12 01:29:14.049323401 +0200
@@ -26,8 +26,8 @@
  * instead of those above.
  */
 
-#include <cstddef> // for NULL
-#include <cmath>
+#include <stddef.h> // for NULL
+#include <math.h>
 
 #include <libwpg/libwpg.h>
 
@@ -38,7 +38,10 @@
 
 #define CALCULATED_VALUE | 0x80000000
 
-#define PI 3.14159265
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 
 using namespace libmspub;
 
@@ -6034,15 +6037,15 @@
           //
           // assuming eccentric anomaly for now
           WPXPropertyList moveVertex;
-          Vector2D start(cx + rx * cos(startAngle * PI / 180),
-                         cy + ry * sin(startAngle * PI / 180));
+          Vector2D start(cx + rx * cos(startAngle * M_PI / 180),
+                         cy + ry * sin(startAngle * M_PI / 180));
           start = transform.transformWithOrigin(start, center);
           moveVertex.insert("libwpg:path-action", "M");
           moveVertex.insert("svg:x", start.m_x);
           moveVertex.insert("svg:y", start.m_y);
           vertices.append(moveVertex);
-          Vector2D half(cx + rx * cos(endAngle * PI / 360),
-                        cy + ry * sin(endAngle * PI / 360));
+          Vector2D half(cx + rx * cos(endAngle * M_PI / 360),
+                        cy + ry * sin(endAngle * M_PI / 360));
           half = transform.transformWithOrigin(half, center);
           WPXPropertyList halfVertex;
           halfVertex.insert("libwpg:path-action", "A");
@@ -6052,8 +6055,8 @@
           halfVertex.insert("svg:ry", ry * transform.getVerticalScaling());
           halfVertex.insert("libwpg:rotate", transform.getRotation() * 180 / M_PI);
           vertices.append(halfVertex);
-          Vector2D end(cx + rx * cos(endAngle * PI / 180),
-                       cy + ry * sin(endAngle * PI / 180));
+          Vector2D end(cx + rx * cos(endAngle * M_PI / 180),
+                       cy + ry * sin(endAngle * M_PI / 180));
           end = transform.transformWithOrigin(end, center);
           vertex.insert("svg:x", end.m_x);
           vertex.insert("svg:y", end.m_y);
--- misc/libmspub-0.0.1/src/lib/ShapeGroup.h	2012-07-10 08:13:15.000000000 +0200
+++ misc/build/libmspub-0.0.1/src/lib/ShapeGroup.h	2012-07-12 01:29:28.154982030 +0200
@@ -14,7 +14,7 @@
   ShapeGroup *m_parent;
   VectorTransformation2D m_transform;
   Coordinate m_coordinates;
-  ShapeGroupElement(ShapeGroup *parent) : m_parent(parent), m_transform(IDENTITY_TRANSFORMATION), m_coordinates()
+  ShapeGroupElement(ShapeGroup *parent) : m_parent(parent), m_transform(VectorTransformation2D()), m_coordinates()
   {
   }
   virtual unsigned getPageSeqNum() const = 0;
--- misc/libmspub-0.0.1/src/lib/Shapes.h	2012-07-10 08:13:15.000000000 +0200
+++ misc/build/libmspub-0.0.1/src/lib/Shapes.h	2012-07-12 01:29:28.155982003 +0200
@@ -105,21 +105,21 @@
   unsigned m_left, m_top, m_right, m_bottom; //emu
   GeometricShape(MSPUBCollector *o)
     : FillableShape(o), m_str(), m_hasText(false), m_pageSeqNum(0), m_imgIndex(0), m_type(RECTANGLE),
-      m_x(0), m_y(0), m_width(0), m_height(0), m_transform(IDENTITY_TRANSFORMATION),
+      m_x(0), m_y(0), m_width(0), m_height(0), m_transform(VectorTransformation2D()),
       m_adjustValues(),
       m_left(DEFAULT_MARGIN), m_top(DEFAULT_MARGIN), m_right(DEFAULT_MARGIN), m_bottom(DEFAULT_MARGIN),
       m_valuesSeen(), m_filledDefaultAdjustValues(false), m_textCoord(), m_closeEverything(false),
       m_lines(), m_drawStroke(false),
       m_borderPosition(HALF_INSIDE_SHAPE),
-      m_coordinatesRotated90(false), m_foldedTransform(IDENTITY_TRANSFORMATION) { }
+      m_coordinatesRotated90(false), m_foldedTransform(VectorTransformation2D()) { }
   GeometricShape(unsigned pageSeqNum, MSPUBCollector *o)
     : FillableShape(o), m_str(), m_hasText(false), m_pageSeqNum(pageSeqNum), m_imgIndex(0), m_type(RECTANGLE),
-      m_x(0), m_y(0), m_width(0), m_height(0), m_transform(IDENTITY_TRANSFORMATION), m_adjustValues(),
+      m_x(0), m_y(0), m_width(0), m_height(0), m_transform(VectorTransformation2D()), m_adjustValues(),
       m_left(DEFAULT_MARGIN), m_top(DEFAULT_MARGIN), m_right(DEFAULT_MARGIN), m_bottom(DEFAULT_MARGIN),
       m_valuesSeen(), m_filledDefaultAdjustValues(false), m_textCoord(), m_closeEverything(false),
       m_lines(), m_drawStroke(false),
       m_borderPosition(HALF_INSIDE_SHAPE),
-      m_coordinatesRotated90(false), m_foldedTransform(IDENTITY_TRANSFORMATION) { }
+      m_coordinatesRotated90(false), m_foldedTransform(VectorTransformation2D()) { }
   std::vector<Color> getPaletteColors() const;
   void output(libwpg::WPGPaintInterface *painter, Coordinate coord);
 protected:
--- misc/libmspub-0.0.1/src/lib/VectorTransformation2D.cpp
+++ misc/build/libmspub-0.0.1/src/lib/VectorTransformation2D.cpp
@@ -29,7 +29,7 @@
 #include "VectorTransformation2D.h"
 #include <math.h>
 
-libmspub::VectorTransformation2D::VectorTransformation2D() : m_m11(0), m_m12(0), m_m21(0), m_m22(0), m_x(0), m_y(0)
+libmspub::VectorTransformation2D::VectorTransformation2D() : m_m11(1), m_m12(0), m_m21(0), m_m22(1), m_x(0), m_y(0)
 {
 }
 
--- misc/libmspub-0.0.1/src/lib/VectorTransformation2D.h	2012-07-10 08:13:15.000000000 +0200
+++ misc/build/libmspub-0.0.1/src/lib/VectorTransformation2D.h	2012-07-12 01:29:28.155982003 +0200
@@ -45,8 +45,8 @@
 {
   double m_m11, m_m12, m_m21, m_m22;
   double m_x, m_y;
-  VectorTransformation2D();
 public:
+  VectorTransformation2D();
   Vector2D transform(Vector2D original) const;
   Vector2D transformWithOrigin(Vector2D v, Vector2D origin) const;
   double getRotation() const;
@@ -58,7 +58,6 @@
   static VectorTransformation2D fromCounterRadians(double theta);
 };
 VectorTransformation2D operator*(const VectorTransformation2D &l, const VectorTransformation2D &r);
-const VectorTransformation2D IDENTITY_TRANSFORMATION = VectorTransformation2D::fromFlips(false, false);
 } // namespace libmspub
 
 #endif /* __VECTORTRANSFORMATION2D_H__ */
--- misc/libmspub-0.0.1/src/lib/libmspub_utils.cpp	2012-07-10 08:13:15.000000000 +0200
+++ misc/build/libmspub-0.0.1/src/lib/libmspub_utils.cpp	2012-07-12 01:29:14.050323377 +0200
@@ -30,9 +30,14 @@
  */
 
 #include <string.h> // for memcpy
+#include <math.h>
 #include <zlib.h>
 #include "libmspub_utils.h"
 
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
 #define ZLIB_CHUNK 16384
 
 const char *libmspub::mimeByImgType(ImgType type)
@@ -63,8 +68,8 @@
 {
   double vecX = x - centerX;
   double vecY = centerY - y;
-  double sinTheta = sin(rotation * PI / 180.);
-  double cosTheta = cos(rotation * PI / 180.);
+  double sinTheta = sin(rotation * M_PI / 180.);
+  double cosTheta = cos(rotation * M_PI / 180.);
   double newVecX = cosTheta * vecX - sinTheta * vecY;
   double newVecY = sinTheta * vecX + cosTheta * vecY;
   x = centerX + newVecX;
--- misc/libmspub-0.0.1/src/lib/libmspub_utils.h	2012-07-10 08:13:15.000000000 +0200
+++ misc/build/libmspub-0.0.1/src/lib/libmspub_utils.h	2012-07-12 01:29:14.050323377 +0200
@@ -30,10 +30,7 @@
 #ifndef __LIBMSPUB_UTILS_H__
 #define __LIBMSPUB_UTILS_H__
 
-const double PI = 3.1415926;
-
 #include <stdio.h>
-#include <cmath>
 #include <vector>
 #include <map>
 #include <boost/ptr_container/ptr_map.hpp>