--- misc/libmspub-0.0.1/src/lib/ColorReference.cpp 2012-07-11 23:03:45.000000000 +0200 +++ misc/build/libmspub-0.0.1/src/lib/ColorReference.cpp 2012-07-12 15:13:47.840592701 +0200 @@ -44,13 +44,13 @@ return l.m_baseColor == r.m_baseColor && l.m_modifiedColor == r.m_modifiedColor; } -// const unsigned char ColorReference::COLOR_PALETTE; +// const unsigned char ColorReference::COLOR_PALETTE = 0x8; -const unsigned char ColorReference::CHANGE_INTENSITY; +const unsigned char ColorReference::CHANGE_INTENSITY = 0x10; -const unsigned char ColorReference::BLACK_BASE; +const unsigned char ColorReference::BLACK_BASE = 0x1; -const unsigned char ColorReference::WHITE_BASE; +const unsigned char ColorReference::WHITE_BASE = 0x2; } --- misc/libmspub-0.0.1/src/lib/ColorReference.h 2012-07-11 23:03:07.000000000 +0200 +++ misc/build/libmspub-0.0.1/src/lib/ColorReference.h 2012-07-12 15:13:47.840592701 +0200 @@ -37,10 +37,10 @@ { unsigned m_baseColor; unsigned m_modifiedColor; -// static const unsigned char COLOR_PALETTE = 0x8; - static const unsigned char CHANGE_INTENSITY = 0x10; - static const unsigned char BLACK_BASE = 0x1; - static const unsigned char WHITE_BASE = 0x2; +// static const unsigned char COLOR_PALETTE; + static const unsigned char CHANGE_INTENSITY; + static const unsigned char BLACK_BASE; + static const unsigned char WHITE_BASE; Color getRealColor(unsigned c, const std::vector &palette) const; public: explicit ColorReference(unsigned color) : m_baseColor(color), m_modifiedColor(color) { } --- 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 15:13:47.841592676 +0200 @@ -28,6 +28,7 @@ * instead of those above. */ +#include #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 *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 *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 15:13:47.841592676 +0200 @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -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 15:14:04.325188736 +0200 @@ -26,8 +26,8 @@ * instead of those above. */ -#include // for NULL -#include +#include // for NULL +#include #include @@ -38,7 +38,10 @@ #define CALCULATED_VALUE | 0x80000000 -#define PI 3.14159265 +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + using namespace libmspub; @@ -5735,7 +5738,7 @@ bool drawStroke, WPXPropertyList &graphicsProps, libwpg::WPGPaintInterface *painter) { std::vector lineInfos; - std::vector::const_iterator iter_line = lines.begin(); + unsigned i_line = 0; bool rectangle = isShapeTypeRectangle(shapeType) && !lines.empty(); // ugly HACK: special handling for rectangle outlines. Vector2D vector(0, 0); Vector2D old(0, 0); @@ -5746,7 +5749,7 @@ if (i > 0) { WPXPropertyList vertexStart; - double lineWidth = (double)(iter_line->m_widthInEmu) / EMUS_IN_INCH; + double lineWidth = (double)(lines[i_line].m_widthInEmu) / EMUS_IN_INCH; switch (i - 1) // fudge the lines inward by half their width so they are fully inside the shape and hence proper borders { case 0: @@ -5772,7 +5775,7 @@ old = vector; if (rectangle) { - double lineWidth = (double)(iter_line->m_widthInEmu) / EMUS_IN_INCH; + double lineWidth = (double)(lines[i_line].m_widthInEmu) / EMUS_IN_INCH; switch (i) // fudge the lines inward by half their width so they are fully inside the shape and hence proper borders { case 1: @@ -5795,12 +5798,12 @@ vertices.append(vertex); if (i > 0) { - lineInfos.push_back(LineInfo(vertices, *iter_line, caller->getPaletteColors())); + lineInfos.push_back(LineInfo(vertices, lines[i_line], caller->getPaletteColors())); if (drawStroke) { - if (iter_line + 1 < lines.end()) // continue using the last element if we run out of lines. + if (i_line + 1 < lines.size()) // continue using the last element if we run out of lines. { - ++iter_line; + ++i_line; } } } @@ -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 15:13:47.843592626 +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 15:13:47.844592602 +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 getPaletteColors() const; void output(libwpg::WPGPaintInterface *painter, Coordinate coord); protected: --- misc/libmspub-0.0.1/src/lib/VectorTransformation2D.cpp 2012-07-10 08:13:15.000000000 +0200 +++ misc/build/libmspub-0.0.1/src/lib/VectorTransformation2D.cpp 2012-07-12 15:13:47.844592602 +0200 @@ -29,7 +29,7 @@ #include "VectorTransformation2D.h" #include -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 15:13:47.844592602 +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 15:13:47.844592602 +0200 @@ -30,9 +30,14 @@ */ #include // for memcpy +#include #include #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 15:13:47.845592578 +0200 @@ -30,10 +30,7 @@ #ifndef __LIBMSPUB_UTILS_H__ #define __LIBMSPUB_UTILS_H__ -const double PI = 3.1415926; - #include -#include #include #include #include